Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information...
kvet committed Mar 30, 2017
0 parents commit 49ce6b716619b5a0ed93558136278e366021b2dd
Showing with 5,141 additions and 0 deletions.
  1. +11 −0 .editorconfig
  2. +1 −0 .gitattributes
  3. +4 −0 .gitignore
  4. +49 −0 .vscode/launch.json
  5. +7 −0 .vscode/settings.json
  6. +1 −0 README.md
  7. +7 −0 lerna.json
  8. +20 −0 package.json
  9. +3 −0 packages/dx-core/.babelrc
  10. +13 −0 packages/dx-core/.eslintrc.json
  11. +34 −0 packages/dx-core/package.json
  12. +1 −0 packages/dx-core/src/index.js
  13. +50 −0 packages/dx-core/src/plugin-host.js
  14. +128 −0 packages/dx-core/src/plugin-host.test.js
  15. +28 −0 packages/dx-core/webpack.config.js
  16. +3 −0 packages/dx-datagrid-core/.babelrc
  17. +14 −0 packages/dx-datagrid-core/.eslintrc.json
  18. +37 −0 packages/dx-datagrid-core/package.json
  19. +19 −0 packages/dx-datagrid-core/src/index.js
  20. +7 −0 packages/dx-datagrid-core/src/plugins/_blueprint/computeds.js
  21. +14 −0 packages/dx-datagrid-core/src/plugins/_blueprint/computeds.test.js
  22. +7 −0 packages/dx-datagrid-core/src/plugins/_blueprint/helpers.js
  23. +14 −0 packages/dx-datagrid-core/src/plugins/_blueprint/helpers.test.js
  24. +7 −0 packages/dx-datagrid-core/src/plugins/_blueprint/reducers.js
  25. +15 −0 packages/dx-datagrid-core/src/plugins/_blueprint/reducers.test.js
  26. +17 −0 packages/dx-datagrid-core/src/plugins/detail-row/computeds.js
  27. +50 −0 packages/dx-datagrid-core/src/plugins/detail-row/computeds.test.js
  28. +1 −0 packages/dx-datagrid-core/src/plugins/detail-row/helpers.js
  29. +14 −0 packages/dx-datagrid-core/src/plugins/detail-row/helpers.test.js
  30. +13 −0 packages/dx-datagrid-core/src/plugins/detail-row/reducers.js
  31. +45 −0 packages/dx-datagrid-core/src/plugins/detail-row/reducers.test.js
  32. +10 −0 packages/dx-datagrid-core/src/plugins/filtering-state/computeds.js
  33. +40 −0 packages/dx-datagrid-core/src/plugins/filtering-state/computeds.test.js
  34. +6 −0 packages/dx-datagrid-core/src/plugins/filtering-state/helpers.js
  35. +21 −0 packages/dx-datagrid-core/src/plugins/filtering-state/helpers.test.js
  36. +16 −0 packages/dx-datagrid-core/src/plugins/filtering-state/reducers.js
  37. +42 −0 packages/dx-datagrid-core/src/plugins/filtering-state/reducers.test.js
  38. +61 −0 packages/dx-datagrid-core/src/plugins/grouping-state/computeds.js
  39. +122 −0 packages/dx-datagrid-core/src/plugins/grouping-state/computeds.test.js
  40. +19 −0 packages/dx-datagrid-core/src/plugins/grouping-state/reducers.js
  41. +47 −0 packages/dx-datagrid-core/src/plugins/grouping-state/reducers.test.js
  42. +25 −0 packages/dx-datagrid-core/src/plugins/paging-state/computeds.js
  43. +49 −0 packages/dx-datagrid-core/src/plugins/paging-state/computeds.test.js
  44. +1 −0 packages/dx-datagrid-core/src/plugins/paging-state/reducers.js
  45. +15 −0 packages/dx-datagrid-core/src/plugins/paging-state/reducers.test.js
  46. +24 −0 packages/dx-datagrid-core/src/plugins/selection-state/reducers.js
  47. +56 −0 packages/dx-datagrid-core/src/plugins/selection-state/reducers.test.js
  48. +75 −0 packages/dx-datagrid-core/src/plugins/sorting-state/computeds.js
  49. +69 −0 packages/dx-datagrid-core/src/plugins/sorting-state/computeds.test.js
  50. +4 −0 packages/dx-datagrid-core/src/plugins/sorting-state/helpers.js
  51. +21 −0 packages/dx-datagrid-core/src/plugins/sorting-state/helpers.test.js
  52. +21 −0 packages/dx-datagrid-core/src/plugins/sorting-state/reducers.js
  53. +55 −0 packages/dx-datagrid-core/src/plugins/sorting-state/reducers.test.js
  54. +31 −0 packages/dx-datagrid-core/webpack.config.js
  55. +3 −0 packages/dx-react-core/.babelrc
  56. +16 −0 packages/dx-react-core/.eslintrc.json
  57. +43 −0 packages/dx-react-core/package.json
  58. +1 −0 packages/dx-react-core/src/index.js
  59. +32 −0 packages/dx-react-core/src/plugged/action.jsx
  60. +36 −0 packages/dx-react-core/src/plugged/action.test.jsx
  61. +79 −0 packages/dx-react-core/src/plugged/getter.jsx
  62. +253 −0 packages/dx-react-core/src/plugged/getter.test.jsx
  63. +40 −0 packages/dx-react-core/src/plugged/host.jsx
  64. +24 −0 packages/dx-react-core/src/plugged/host.test.jsx
  65. +5 −0 packages/dx-react-core/src/plugged/index.js
  66. +86 −0 packages/dx-react-core/src/plugged/template-connector.jsx
  67. +89 −0 packages/dx-react-core/src/plugged/template-placeholder.jsx
  68. +147 −0 packages/dx-react-core/src/plugged/template-placeholder.test.jsx
  69. +59 −0 packages/dx-react-core/src/plugged/template.jsx
  70. +51 −0 packages/dx-react-core/src/plugged/template.test.jsx
  71. +46 −0 packages/dx-react-core/src/utils/shallowEqual.js
  72. +32 −0 packages/dx-react-core/webpack.config.js
  73. +5 −0 packages/dx-react-datagrid-bootstrap3/.babelrc
  74. +18 −0 packages/dx-react-datagrid-bootstrap3/.eslintrc.json
  75. +44 −0 packages/dx-react-datagrid-bootstrap3/package.json
  76. +10 −0 packages/dx-react-datagrid-bootstrap3/src/index.js
  77. +6 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/grouping-panel.jsx
  78. +6 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/paging-panel.jsx
  79. +12 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-column-selection.jsx
  80. +7 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-filter-row.jsx
  81. +10 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-group-row.jsx
  82. +9 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-header-row-grouping.jsx
  83. +9 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-header-row-sorting.jsx
  84. +29 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-row-detail.jsx
  85. +27 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/table-view.jsx
  86. +25 −0 packages/dx-react-datagrid-bootstrap3/src/plugins/virtual-table-view.jsx
  87. +21 −0 packages/dx-react-datagrid-bootstrap3/src/templates/filter-cell.jsx
  88. +29 −0 packages/dx-react-datagrid-bootstrap3/src/templates/group-panel.jsx
  89. +17 −0 packages/dx-react-datagrid-bootstrap3/src/templates/group-row-cell.jsx
  90. +24 −0 packages/dx-react-datagrid-bootstrap3/src/templates/groupable-cell.jsx
  91. +22 −0 packages/dx-react-datagrid-bootstrap3/src/templates/layout.jsx
  92. +19 −0 packages/dx-react-datagrid-bootstrap3/src/templates/pager.jsx
  93. +22 −0 packages/dx-react-datagrid-bootstrap3/src/templates/select-all-cell.jsx
  94. +15 −0 packages/dx-react-datagrid-bootstrap3/src/templates/select-cell.jsx
  95. +33 −0 packages/dx-react-datagrid-bootstrap3/src/templates/sortable-cell.jsx
  96. +15 −0 packages/dx-react-datagrid-bootstrap3/src/templates/table-detail-toggle.jsx
  97. +115 −0 packages/dx-react-datagrid-bootstrap3/src/templates/table.jsx
  98. +166 −0 packages/dx-react-datagrid-bootstrap3/src/templates/virtual-table.jsx
  99. +41 −0 packages/dx-react-datagrid-bootstrap3/src/templates/virtual-table/sizer.jsx
  100. +210 −0 packages/dx-react-datagrid-bootstrap3/src/templates/virtual-table/virtual-box.jsx
  101. +93 −0 packages/dx-react-datagrid-bootstrap3/src/templates/virtual-table/windowed-scroller.jsx
  102. +34 −0 packages/dx-react-datagrid-bootstrap3/webpack.config.js
  103. +5 −0 packages/dx-react-datagrid/.babelrc
  104. +17 −0 packages/dx-react-datagrid/.eslintrc.json
  105. +43 −0 packages/dx-react-datagrid/package.json
  106. +27 −0 packages/dx-react-datagrid/src/datagrid.jsx
  107. +19 −0 packages/dx-react-datagrid/src/index.js
  108. +57 −0 packages/dx-react-datagrid/src/plugins/filtering-state.jsx
  109. +49 −0 packages/dx-react-datagrid/src/plugins/grouping-panel.jsx
  110. +99 −0 packages/dx-react-datagrid/src/plugins/grouping-state.jsx
  111. +29 −0 packages/dx-react-datagrid/src/plugins/paging-panel.jsx
  112. +82 −0 packages/dx-react-datagrid/src/plugins/paging-state.jsx
  113. +54 −0 packages/dx-react-datagrid/src/plugins/selection-state.jsx
  114. +59 −0 packages/dx-react-datagrid/src/plugins/sorting-state.jsx
  115. +69 −0 packages/dx-react-datagrid/src/plugins/table-column-selection.jsx
  116. +46 −0 packages/dx-react-datagrid/src/plugins/table-filter-row.jsx
  117. +55 −0 packages/dx-react-datagrid/src/plugins/table-group-row.jsx
  118. +28 −0 packages/dx-react-datagrid/src/plugins/table-header-row-grouping.jsx
  119. +32 −0 packages/dx-react-datagrid/src/plugins/table-header-row-sorting.jsx
  120. +28 −0 packages/dx-react-datagrid/src/plugins/table-header-row.jsx
  121. +74 −0 packages/dx-react-datagrid/src/plugins/table-row-detail.jsx
  122. +89 −0 packages/dx-react-datagrid/src/plugins/table-view.jsx
  123. +19 −0 packages/dx-react-datagrid/src/utils/memoize.js
  124. +33 −0 packages/dx-react-datagrid/webpack.config.js
  125. +4 −0 packages/dx-react-demos/.babelrc
  126. +11 −0 packages/dx-react-demos/.eslintrc.json
  127. +16 −0 packages/dx-react-demos/index.html
  128. +45 −0 packages/dx-react-demos/package.json
  129. +39 −0 packages/dx-react-demos/src/demoData.js
  130. +87 −0 packages/dx-react-demos/src/full-featured-controlled.jsx
  131. +85 −0 packages/dx-react-demos/src/full-featured-uncontrolled.jsx
  132. +18 −0 packages/dx-react-demos/src/index.css
  133. +26 −0 packages/dx-react-demos/src/index.jsx
  134. +74 −0 packages/dx-react-demos/src/uncontrolled-grouped-virtual.jsx
  135. +71 −0 packages/dx-react-demos/src/uncontrolled-virtual.jsx
  136. +53 −0 packages/dx-react-demos/webpack.config.js
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = null
@@ -0,0 +1 @@
* text eol=lf
@@ -0,0 +1,4 @@
**/node_modules
**/dist
**/coverage
*.log
@@ -0,0 +1,49 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
},
{
"name" : "Run dx-react-core tests",
"type": "node",
"request": "launch",
"program" : "${workspaceRoot}/packages/dx-react-core/node_modules/jest/bin/jest.js",
"cwd": "${workspaceRoot}/packages/dx-react-core/",
"args": [
"--runInBand"
],
"runtimeArgs": [
"--harmony"
],
"sourceMaps": true
},
{
"name" : "Run dx-datagrid-core tests",
"type": "node",
"request": "launch",
"program" : "${workspaceRoot}/packages/dx-datagrid-core/node_modules/jest/bin/jest.js",
"cwd": "${workspaceRoot}/packages/dx-datagrid-core/",
"args": [
"--runInBand"
],
"runtimeArgs": [
"--harmony"
],
"sourceMaps": true
}
]
}
@@ -0,0 +1,7 @@
// Place your settings in this file to overwrite default and user settings.
{
"search.exclude": {
"**/node_modules": true,
"**/dist": true
}
}
@@ -0,0 +1 @@
"# devextreme-reactive"
@@ -0,0 +1,7 @@
{
"lerna": "2.0.0-beta.38",
"packages": [
"packages/*"
],
"version": "0.0.0"
}
@@ -0,0 +1,20 @@
{
"private": true,
"devDependencies": {
"concurrently": "^3.4.0",
"lerna": "2.0.0-beta.38"
},
"scripts": {
"postinstall": "lerna bootstrap",
"build": "lerna run build",
"watch:core": "lerna run build:watch --scope @devexpress/dx-core --stream",
"watch:datagrid-core": "lerna run build:watch --scope @devexpress/dx-datagrid-core --stream",
"watch:react-core": "lerna run build:watch --scope @devexpress/dx-react-core --stream",
"watch:react-datagrid": "lerna run build:watch --scope @devexpress/dx-react-datagrid --stream",
"watch:react-datagrid-bootstrap3": "lerna run build:watch --scope @devexpress/dx-react-datagrid-bootstrap3 --stream",
"watch:react-demos": "lerna run watch --scope @devexpress/dx-react-demos --stream",
"watch": "concurrently --kill-others \"npm run watch:core\" \"npm run watch:datagrid-core\" \"npm run watch:react-core\" \"npm run watch:react-datagrid\" \"npm run watch:react-datagrid-bootstrap3\" \"npm run watch:react-demos\"",
"lint": "lerna run lint",
"test": "lerna run test"
}
}
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
@@ -0,0 +1,13 @@
{
"extends": "airbnb-base",
"plugins": [
"import",
"jest"
],
"rules": {
"import/prefer-default-export": "off"
},
"env": {
"jest/globals": true
}
}
@@ -0,0 +1,34 @@
{
"name": "@devexpress/dx-core",
"version": "0.0.0",
"description": "",
"main": "dist/index",
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"build": "webpack",
"build:watch": "webpack --watch",
"lint": "eslint src/**/*",
"lint:fix": "eslint --fix src/**/*"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-jest": "^19.0.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-runtime": "^6.20.0",
"core-js": "^2.4.1",
"eslint": "^3.18.0",
"eslint-config-airbnb-base": "^11.1.2",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jest": "^19.0.1",
"jest": "^19.0.2",
"webpack": "^2.2.1"
}
}
@@ -0,0 +1 @@
export * from './plugin-host';
@@ -0,0 +1,50 @@
export class PluginHost {
constructor() {
this.plugins = [];
this.subscriptions = [];
this.gettersCache = {};
}
registerPlugin(plugin) {
this.plugins.push(plugin);
this.cleanPluginsCache();
}
unregisterPlugin(plugin) {
this.plugins.splice(this.plugins.indexOf(plugin), 1);
this.cleanPluginsCache();
}
cleanPluginsCache() {
this.gettersCache = {};
}
collect(key, upTo) {
if (!this.gettersCache[key]) {
this.gettersCache[key] = this.plugins.map(plugin => plugin[key]).filter(plugin => !!plugin);
}
if (!upTo) return this.gettersCache[key];

const upToIndex = this.plugins.indexOf(upTo);
return this.gettersCache[key].filter((getter) => {
const pluginIndex = this.plugins.findIndex(plugin => plugin[key] === getter);
return pluginIndex < upToIndex;
});
}
get(key, upTo) {
const plugins = this.collect(key, upTo);

let result = plugins[0]();
plugins.slice(1).forEach((plugin) => {
result = plugin(result);
});
return result;
}
registerSubscription(subscription) {
const index = this.subscriptions.indexOf(subscription);
if (index === -1) { this.subscriptions.push(subscription); }
}
unregisterSubscription(subscription) {
const index = this.subscriptions.indexOf(subscription);
if (index !== -1) { this.subscriptions.splice(this.subscriptions.indexOf(subscription), 1); }
}
broadcast(event, message) {
this.subscriptions.forEach(subscription => subscription[event] && subscription[event](message));
}
}
@@ -0,0 +1,128 @@
import { PluginHost } from './plugin-host';

describe('PluginHost', () => {
let host;

beforeEach(() => {
host = new PluginHost();
});

test('#get', () => {
const plugin = {
something: () => 123,
};

host.registerPlugin(plugin);
expect(host.get('something')).toBe(123);
});

test('#get with extender', () => {
const plugin1 = {
something: () => '1',
};
const plugin2 = {
something: original => `${original}2`,
};
const plugin3 = {
something: original => `${original}3`,
};

host.registerPlugin(plugin1);
host.registerPlugin(plugin2);
host.registerPlugin(plugin3);
expect(host.get('something')).toBe('123');
});

test('#get clean cache', () => {
const plugin1 = {
something: () => '1',
};
const plugin2 = {
something: original => `${original}2`,
};

host.registerPlugin(plugin1);
host.registerPlugin(plugin2);
host.get('something');

host.unregisterPlugin(plugin2);
expect(host.get('something')).toBe('1');

host.registerPlugin(plugin2);
expect(host.get('something')).toBe('12');
});

test('#collect', () => {
const plugin1 = {
something: 1,
};
const plugin2 = {
something: 2,
};
const plugin3 = {
something: 3,
};

host.registerPlugin(plugin1);
host.registerPlugin(plugin2);
host.registerPlugin(plugin3);
expect(host.collect('something')).toEqual([1, 2, 3]);
});

test('#registerSubscription', () => {
const subscription = {
onMessage: jest.fn(),
};

host.registerSubscription(subscription);
host.broadcast('onMessage', 'update');
expect(subscription.onMessage.mock.calls.length).toBe(1);
});

test('#registerSubscription several times', () => {
const subscription = {
onMessage: jest.fn(),
};

host.registerSubscription(subscription);
host.registerSubscription(subscription);
host.broadcast('onMessage', 'update');
expect(subscription.onMessage.mock.calls.length).toBe(1);
});

test('#unregisterSubscription', () => {
const subscription = {
onMessage: jest.fn(),
};

host.registerSubscription(subscription);
host.unregisterSubscription(subscription);
host.broadcast('onMessage', 'update');
expect(subscription.onMessage.mock.calls.length).toBe(0);
});

test('#unregisterSubscription without registration', () => {
const subscription1 = {
onMessage: jest.fn(),
};
const subscription2 = {
onMessage: jest.fn(),
};

host.registerSubscription(subscription1);
host.unregisterSubscription(subscription2);
host.broadcast('onMessage', 'update');
expect(subscription1.onMessage.mock.calls.length).toBe(1);
});

test('#registerSubscription', () => {
const subscription = {
onMessage: jest.fn(),
};

host.registerSubscription(subscription);
host.broadcast('onMessage', 'update');
expect(subscription.onMessage.mock.calls[0].length).toBe(1);
expect(subscription.onMessage.mock.calls[0][0]).toBe('update');
});
});
@@ -0,0 +1,28 @@
/* eslint-disable */

var path = require('path');
var webpack = require('webpack');

module.exports = {
context: __dirname,
entry: {
index: './src/index'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components|public\/)/,
use: ["babel-loader"]
}
]
},
resolve: {
extensions: [".webpack.js", ".web.js", ".js"]
},
}
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
@@ -0,0 +1,14 @@
{
"extends": "airbnb-base",
"plugins": [
"import",
"jest"
],
"rules": {
"import/prefer-default-export": "off",
"no-underscore-dangle": "off"
},
"env": {
"jest/globals": true
}
}

0 comments on commit 49ce6b7

Please sign in to comment.
You can’t perform that action at this time.