Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit cd73884

Browse files
committed
Revert "Remove compiled files and add postinstall step"
This reverts commit e0f5fcc.
1 parent 9e4628a commit cd73884

File tree

8 files changed

+927
-2
lines changed

8 files changed

+927
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ node_modules
2828
dev-build
2929
.tern-port
3030
npm-debug.log*
31-
build/

build/index.js

Lines changed: 486 additions & 0 deletions
Large diffs are not rendered by default.

build/layout.js

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', {
4+
value: true
5+
});
6+
7+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8+
9+
var _platform = require('./platform');
10+
11+
var _utils = require('./utils');
12+
13+
/* Axes System
14+
15+
This allows us to at-will work in a different orientation
16+
without having to manually keep track of knowing if we should be using
17+
x or y positions. */
18+
19+
var axes = {
20+
row: {},
21+
column: {}
22+
};
23+
24+
axes.row.main = {
25+
start: 'x',
26+
end: 'x2',
27+
size: 'w'
28+
};
29+
axes.row.cross = {
30+
start: 'y',
31+
end: 'y2',
32+
size: 'h'
33+
};
34+
axes.column.main = axes.row.cross;
35+
axes.column.cross = axes.row.main;
36+
37+
var types = [{ name: 'side', values: ['start', 'end'] }, { name: 'standing', values: ['above', 'right', 'below', 'left'] }, { name: 'flow', values: ['column', 'row'] }];
38+
39+
var validTypeValues = types.reduce(function (xs, _ref2) {
40+
var values = _ref2.values;
41+
return xs.concat(values);
42+
}, []);
43+
44+
var centerOfSize = function centerOfSize(flow, axis, size) {
45+
return size[axes[flow][axis].size] / 2;
46+
};
47+
48+
var centerOfBounds = function centerOfBounds(flow, axis, bounds) {
49+
return bounds[axes[flow][axis].start] + bounds[axes[flow][axis].size] / 2;
50+
};
51+
52+
var centerOfBoundsFromBounds = function centerOfBoundsFromBounds(flow, axis, boundsTo, boundsFrom) {
53+
return centerOfBounds(flow, axis, boundsTo) - boundsFrom[axes[flow][axis].start];
54+
};
55+
56+
var place = function place(flow, axis, align, bounds, size) {
57+
var axisProps = axes[flow][axis];
58+
return align === 'center' ? centerOfBounds(flow, axis, bounds) - centerOfSize(flow, axis, size) : align === 'end' ? bounds[axisProps.end] : align === 'start'
59+
/* DOM rendering unfolds leftward. Therefore if the slave is positioned before
60+
the master then the slave`s position must in addition be pulled back
61+
by its [the slave`s] own length. */
62+
? bounds[axisProps.start] - size[axisProps.size] : null;
63+
};
64+
65+
/* Element Layout Queries */
66+
67+
var El = {};
68+
69+
El.calcBounds = function (el) {
70+
71+
if (el === _platform.window) {
72+
return {
73+
x: 0,
74+
y: 0,
75+
x2: el.innerWidth,
76+
y2: el.innerHeight,
77+
w: el.innerWidth,
78+
h: el.innerHeight
79+
};
80+
}
81+
82+
var b = el.getBoundingClientRect();
83+
84+
return {
85+
x: b.left,
86+
y: b.top,
87+
x2: b.right,
88+
y2: b.bottom,
89+
w: b.right - b.left,
90+
h: b.bottom - b.top
91+
};
92+
};
93+
94+
El.calcSize = function (el) {
95+
return el === _platform.window ? { w: el.innerWidth, h: el.innerHeight } : { w: el.offsetWidth, h: el.offsetHeight };
96+
};
97+
98+
El.calcScrollSize = function (el) {
99+
return el === _platform.window ? {
100+
w: el.scrollX || el.pageXOffset,
101+
h: el.scrollY || el.pageYOffset
102+
} : { w: el.scrollLeft, h: el.scrollTop };
103+
};
104+
105+
/* Misc Utilities */
106+
107+
var getPreferenceType = function getPreferenceType(preference) {
108+
return types.reduce(function (found, type) {
109+
return found ? found : type.values.indexOf(preference) !== -1 ? type.name : null;
110+
}, null);
111+
};
112+
113+
/* Dimension Fit Checks */
114+
115+
var fitWithinChecker = function fitWithinChecker(dimension) {
116+
return function (domainSize, itemSize) {
117+
return domainSize[dimension] > itemSize[dimension];
118+
};
119+
};
120+
121+
var doesWidthFitWithin = fitWithinChecker('w');
122+
var doesHeightFitWithin = fitWithinChecker('h');
123+
124+
var doesFitWithin = function doesFitWithin(domainSize, itemSize) {
125+
return doesWidthFitWithin(domainSize, itemSize) && doesHeightFitWithin(domainSize, itemSize);
126+
};
127+
128+
/* Errors */
129+
130+
var createPreferenceError = function createPreferenceError(givenValue) {
131+
return new Error('The given layout placement of "' + givenValue + '" is not a valid choice. Valid choices are: ' + validTypeValues.join(' | ') + '.');
132+
};
133+
134+
/* Algorithm for picking the best fitting zone for popover. The current technique will loop through all zones picking the last one that fits. If
135+
none fit the last one is selected.
136+
137+
TODO In the case that none fit we should pick the least-not-fitting zone. */
138+
139+
var pickZone = function pickZone(opts, frameBounds, targetBounds, size) {
140+
var t = targetBounds;
141+
var f = frameBounds;
142+
var zones = [{ side: 'start', standing: 'above', flow: 'column', order: -1, w: f.x2, h: t.y }, { side: 'end', standing: 'right', flow: 'row', order: 1, w: f.x2 - t.x2, h: f.y2 }, { side: 'end', standing: 'below', flow: 'column', order: 1, w: f.x2, h: f.y2 - t.y2 }, { side: 'start', standing: 'left', flow: 'row', order: -1, w: t.x, h: f.y2 }];
143+
144+
var availZones = zones.filter(function (zone) {
145+
return doesFitWithin(zone, size);
146+
});
147+
148+
/* If a place is required pick it from the available zones if possible. */
149+
150+
if (opts.place) {
151+
var _ret = (function () {
152+
var type = getPreferenceType(opts.place);
153+
if (!type) throw createPreferenceError(opts.place);
154+
var finder = function finder(z) {
155+
return z[type] === opts.place;
156+
};
157+
return {
158+
v: (0, _utils.find)(finder, availZones) || (0, _utils.find)(finder, zones)
159+
};
160+
})();
161+
162+
if (typeof _ret === 'object') return _ret.v;
163+
}
164+
165+
/* If the preferred side is part of the available zones, use that otherwise
166+
pick the largest available zone. If there are no available zones, pick the
167+
largest zone. TODO: logic that executes picking based on largest option. */
168+
169+
if (opts.preferPlace) {
170+
var _ret2 = (function () {
171+
var preferenceType = getPreferenceType(opts.preferPlace);
172+
if (!preferenceType) throw createPreferenceError(opts.preferPlace);
173+
var preferredAvailZones = availZones.filter(function (zone) {
174+
return zone[preferenceType] === opts.preferPlace;
175+
});
176+
if (preferredAvailZones.length) return {
177+
v: preferredAvailZones[0]
178+
};
179+
})();
180+
181+
if (typeof _ret2 === 'object') return _ret2.v;
182+
}
183+
184+
return availZones.length ? availZones[0] : zones[0];
185+
};
186+
187+
/* TODO Document this. */
188+
189+
var calcRelPos = function calcRelPos(zone, masterBounds, slaveSize) {
190+
var _ref;
191+
192+
var _axes$zone$flow = axes[zone.flow];
193+
var main = _axes$zone$flow.main;
194+
var cross = _axes$zone$flow.cross;
195+
196+
/* TODO: The slave is hard-coded to align cross-center with master. */
197+
var crossAlign = 'center';
198+
var mainStart = place(zone.flow, 'main', zone.side, masterBounds, slaveSize);
199+
var mainSize = slaveSize[main.size];
200+
var crossStart = place(zone.flow, 'cross', crossAlign, masterBounds, slaveSize);
201+
var crossSize = slaveSize[cross.size];
202+
203+
return (_ref = {}, _defineProperty(_ref, main.start, mainStart), _defineProperty(_ref, 'mainLength', mainSize), _defineProperty(_ref, main.end, mainStart + mainSize), _defineProperty(_ref, cross.start, crossStart), _defineProperty(_ref, 'crossLength', crossSize), _defineProperty(_ref, cross.end, crossStart + crossSize), _ref);
204+
};
205+
206+
exports.types = types;
207+
exports.validTypeValues = validTypeValues;
208+
exports.calcRelPos = calcRelPos;
209+
exports.place = place;
210+
exports.pickZone = pickZone;
211+
exports.axes = axes;
212+
exports.centerOfSize = centerOfSize;
213+
exports.centerOfBounds = centerOfBounds;
214+
exports.centerOfBoundsFromBounds = centerOfBoundsFromBounds;
215+
exports.doesFitWithin = doesFitWithin;
216+
exports.equalCoords = _utils.equalRecords;
217+
exports.El = El;

build/on-resize.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/* eslint no-param-reassign: 0 */
2+
3+
'use strict';
4+
5+
Object.defineProperty(exports, '__esModule', {
6+
value: true
7+
});
8+
9+
var _platform = require('./platform');
10+
11+
var _utils = require('./utils');
12+
13+
var requestAnimationFrame = _platform.isServer ? _utils.noop : _platform.window.requestAnimationFrame || _platform.window.mozRequestAnimationFrame || _platform.window.webkitRequestAnimationFrame || function (fn) {
14+
_platform.window.setTimeout(fn, 20);
15+
};
16+
17+
var cancelAnimationFrame = _platform.isServer ? _utils.noop : _platform.window.cancelAnimationFrame || _platform.window.mozCancelAnimationFrame || _platform.window.webkitCancelAnimationFrame || _platform.window.clearTimeout;
18+
19+
var isIE = _platform.isServer ? false : navigator.userAgent.match(/Trident/);
20+
21+
var namespace = '__resizeDetector__';
22+
23+
var uninitialize = function uninitialize(el) {
24+
el[namespace].destroy();
25+
el[namespace] = undefined;
26+
};
27+
28+
var createElementHack = function createElementHack() {
29+
var el = document.createElement('object');
30+
el.className = 'resize-sensor';
31+
el.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
32+
el.setAttribute('class', 'resize-sensor');
33+
el.type = 'text/html';
34+
el.data = 'about:blank';
35+
return el;
36+
};
37+
38+
var initialize = function initialize(el) {
39+
40+
var detector = el[namespace] = {};
41+
detector.listeners = [];
42+
43+
var onResize = function onResize(e) {
44+
/* Keep in mind e.target could be el OR objEl. In this current implementation we don't seem to need to know this but its important
45+
to not forget e.g. in some future refactoring scenario. */
46+
if (detector.resizeRAF) cancelAnimationFrame(detector.resizeRAF);
47+
detector.resizeRAF = requestAnimationFrame(function () {
48+
detector.listeners.forEach(function (fn) {
49+
fn(e);
50+
});
51+
});
52+
};
53+
54+
if (isIE) {
55+
/* We do not support ie8 and below (or ie9 in compat mode).
56+
Therefore there is no presence of `attachEvent` here. */
57+
el.addEventListener('onresize', onResize);
58+
detector.destroy = function () {
59+
el.removeEventListener('onresize', onResize);
60+
};
61+
} else {
62+
(function () {
63+
if (getComputedStyle(el).position === 'static') {
64+
detector.elWasStaticPosition = true;
65+
el.style.position = 'relative';
66+
}
67+
var objEl = createElementHack();
68+
objEl.onload = function () /* event */{
69+
this.contentDocument.defaultView.addEventListener('resize', onResize);
70+
};
71+
detector.destroy = function () {
72+
if (detector.elWasStaticPosition) el.style.position = '';
73+
// Event handlers will be automatically removed.
74+
// http://stackoverflow.com/questions/12528049/if-a-dom-element-is-removed-are-its-listeners-also-removed-from-memory
75+
el.removeChild(objEl);
76+
};
77+
78+
el.appendChild(objEl);
79+
})();
80+
}
81+
};
82+
83+
var on = function on(el, fn) {
84+
85+
/* Window object natively publishes resize events. We handle it as a
86+
special case here so that users do not have to think about two APIs. */
87+
88+
if (el === _platform.window) {
89+
_platform.window.addEventListener('resize', fn);
90+
return;
91+
}
92+
93+
/* Not caching namespace read here beacuse not guaranteed that its available. */
94+
95+
if (!el[namespace]) initialize(el);
96+
el[namespace].listeners.push(fn);
97+
};
98+
99+
var off = function off(el, fn) {
100+
if (el === _platform.window) {
101+
_platform.window.removeEventListener('resize', fn);
102+
return;
103+
}
104+
var detector = el[namespace];
105+
if (!detector) return;
106+
var i = detector.listeners.indexOf(fn);
107+
if (i !== -1) detector.listeners.splice(i, 1);
108+
if (!detector.listeners.length) uninitialize(el);
109+
};
110+
111+
exports.on = on;
112+
exports.off = off;
113+
exports.addEventListener = on;
114+
exports.removeEventListener = off;

build/platform.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var isServer = typeof window === "undefined";
8+
var isClient = !isServer;
9+
var WINDOW = isClient ? window : null;
10+
11+
exports.isServer = isServer;
12+
exports.isClient = isClient;
13+
exports.window = WINDOW;

build/popover-tip.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', {
4+
value: true
5+
});
6+
7+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
8+
9+
var _react = require('react');
10+
11+
var _react2 = _interopRequireDefault(_react);
12+
13+
var PopoverTip = _react2['default'].createClass({
14+
name: 'tip',
15+
render: function render() {
16+
var direction = this.props.direction;
17+
18+
var size = this.props.size || 24;
19+
var isPortrait = direction === 'up' || direction === 'down';
20+
var mainLength = size;
21+
var crossLength = size * 2;
22+
var points = direction === 'up' ? '0,' + mainLength + ' ' + mainLength + ',0, ' + crossLength + ',' + mainLength : direction === 'down' ? '0,0 ' + mainLength + ',' + mainLength + ', ' + crossLength + ',0' : direction === 'left' ? mainLength + ',0 0,' + mainLength + ', ' + mainLength + ',' + crossLength : '0,0 ' + mainLength + ',' + mainLength + ', 0,' + crossLength;
23+
var props = {
24+
className: 'Popover-tip',
25+
width: isPortrait ? crossLength : mainLength,
26+
height: isPortrait ? mainLength : crossLength
27+
};
28+
var triangle = _react.DOM.svg(props, _react.DOM.polygon({
29+
className: 'Popover-tipShape',
30+
points: points
31+
}));
32+
33+
return triangle;
34+
}
35+
});
36+
37+
exports['default'] = PopoverTip;
38+
module.exports = exports['default'];

0 commit comments

Comments
 (0)