bm-core-ui 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +1624 -0
  2. package/LICENSE +21 -0
  3. package/README.md +145 -0
  4. package/build/@types/index.d.ts +14078 -0
  5. package/build/BMCodeEditor/BMCodeEditor.js +707 -0
  6. package/build/BMCollectionView/BMCollectionView.js +5861 -0
  7. package/build/BMCollectionView/BMCollectionViewCell.js +688 -0
  8. package/build/BMCollectionView/BMCollectionViewFlowLayout.js +4467 -0
  9. package/build/BMCollectionView/BMCollectionViewLayout.js +830 -0
  10. package/build/BMCollectionView/BMCollectionViewLayoutAttributes.js +673 -0
  11. package/build/BMCollectionView/BMCollectionViewMasonryLayout.js +491 -0
  12. package/build/BMCollectionView/BMCollectionViewStackLayout.js +634 -0
  13. package/build/BMCollectionView/BMCollectionViewTileLayout.js +1121 -0
  14. package/build/BMCoreUI.css +2833 -0
  15. package/build/BMView/BMAttributedLabelView.js +310 -0
  16. package/build/BMView/BMLayoutConstraint_v2.5.js +1813 -0
  17. package/build/BMView/BMLayoutGuide.js +192 -0
  18. package/build/BMView/BMLayoutSizeClass.js +466 -0
  19. package/build/BMView/BMMenu.js +574 -0
  20. package/build/BMView/BMScrollView.js +247 -0
  21. package/build/BMView/BMTextField.js +512 -0
  22. package/build/BMView/BMTextFieldDelegate.js +71 -0
  23. package/build/BMView/BMView_v2.5.js +3572 -0
  24. package/build/BMView/BMViewport.js +221 -0
  25. package/build/BMViewLayoutEditor/BMLayoutEditor.js +6117 -0
  26. package/build/BMViewLayoutEditor/BMLayoutEditorConstraintSettings.js +417 -0
  27. package/build/BMViewLayoutEditor/BMLayoutEditorDelegate.js +59 -0
  28. package/build/BMViewLayoutEditor/BMLayoutEditorSettingCells.js +1653 -0
  29. package/build/BMViewLayoutEditor/BMLayoutEditorSettings.js +1480 -0
  30. package/build/BMViewLayoutEditor/BMLayoutEditorSettingsComplexCells.js +431 -0
  31. package/build/BMViewLayoutEditor/BMLayoutEditorSettingsDelegate.js +46 -0
  32. package/build/BMViewLayoutEditor/BMLayoutEditorVariablesController.js +460 -0
  33. package/build/BMViewLayoutEditor/BMLayoutEditorViewGroupSettings.js +293 -0
  34. package/build/BMViewLayoutEditor/BMLayoutEditorViewSettings.js +382 -0
  35. package/build/BMViewLayoutEditor/BMLayoutVariableProvider.js +202 -0
  36. package/build/BMWindow/BMConfirmationPopup.js +477 -0
  37. package/build/BMWindow/BMKeyboardShortcut.js +151 -0
  38. package/build/BMWindow/BMPopover/BMPopover.js +492 -0
  39. package/build/BMWindow/BMToolWindow.js +71 -0
  40. package/build/BMWindow/BMWindow.js +2000 -0
  41. package/build/Core/BMAnimationContext.js +1181 -0
  42. package/build/Core/BMColor.js +991 -0
  43. package/build/Core/BMCoreUI.js +470 -0
  44. package/build/Core/BMFunctionCollection.js +110 -0
  45. package/build/Core/BMIndexPath.js +165 -0
  46. package/build/Core/BMInset.js +138 -0
  47. package/build/Core/BMKeyPath.js +100 -0
  48. package/build/Core/BMPoint.js +291 -0
  49. package/build/Core/BMRect.js +556 -0
  50. package/build/Core/BMSize.js +137 -0
  51. package/build/iScroll/LICENSE +22 -0
  52. package/build/iScroll/iscroll-probe.js +2154 -0
  53. package/build/images/AlignBottom.png +0 -0
  54. package/build/images/AlignCenterX.png +0 -0
  55. package/build/images/AlignCenterY.png +0 -0
  56. package/build/images/AlignLeading.png +0 -0
  57. package/build/images/AlignTop.png +0 -0
  58. package/build/images/AlignTrailing.png +0 -0
  59. package/build/images/AllConstraints.png +0 -0
  60. package/build/images/BottomConstraint.png +0 -0
  61. package/build/images/CenterXConstraint.png +0 -0
  62. package/build/images/CenterYConstraint.png +0 -0
  63. package/build/images/CoreUI2.png +0 -0
  64. package/build/images/CoreUI2@2x.png +0 -0
  65. package/build/images/Desktop.png +0 -0
  66. package/build/images/DesktopMini.png +0 -0
  67. package/build/images/EqualHeight.png +0 -0
  68. package/build/images/EqualHorizontalSpacing.png +0 -0
  69. package/build/images/EqualHorizontalSpacingInSuperview.png +0 -0
  70. package/build/images/EqualVerticalSpacing.png +0 -0
  71. package/build/images/EqualVerticalSpacingInSuperview.png +0 -0
  72. package/build/images/EqualWidth.png +0 -0
  73. package/build/images/HeightConstraint.png +0 -0
  74. package/build/images/InactiveConstraints.png +0 -0
  75. package/build/images/Layout.png +0 -0
  76. package/build/images/LayoutVariables.png +0 -0
  77. package/build/images/LeftConstraint.png +0 -0
  78. package/build/images/OwnConstraints.png +0 -0
  79. package/build/images/Phone.png +0 -0
  80. package/build/images/PhoneLandscape.png +0 -0
  81. package/build/images/PhoneLandscapeMini.png +0 -0
  82. package/build/images/PhoneMini.png +0 -0
  83. package/build/images/PhonePortrait.png +0 -0
  84. package/build/images/PhonePortraitMini.png +0 -0
  85. package/build/images/Properties.png +0 -0
  86. package/build/images/RightConstraint.png +0 -0
  87. package/build/images/SubviewConstraints.png +0 -0
  88. package/build/images/Tablet.png +0 -0
  89. package/build/images/TabletLandscape.png +0 -0
  90. package/build/images/TabletLandscapeMini.png +0 -0
  91. package/build/images/TabletMini.png +0 -0
  92. package/build/images/TabletPortrait.png +0 -0
  93. package/build/images/TabletPortraitMini.png +0 -0
  94. package/build/images/TopConstraint.png +0 -0
  95. package/build/images/WidthConstraint.png +0 -0
  96. package/build/index.js +40 -0
  97. package/lib/@types/BMCoreUI.min.d.ts +14078 -0
  98. package/lib/BMCoreUI.min.js +1 -0
  99. package/package.json +58 -0
@@ -0,0 +1,221 @@
1
+ // @ts-check
2
+
3
+ import {YES, NO} from '../Core/BMCoreUI'
4
+ import {BMLayoutOrientation} from './BMLayoutSizeClass'
5
+
6
+ // @type BMViewport
7
+
8
+ /**
9
+ * A `BMViewport` is an object that describes the characteristics of a viewport, screen or portion of the viewport.
10
+ * They are used by CoreUI to apply specific variations to constraints and view properties based on the current device and
11
+ * browser configuration.
12
+ *
13
+ * Typically you don't create viewport objects manually; instead, the root of the view hierarchy will provide an appropriate
14
+ * viewport specification via its `viewport` property. It is also typically not required to actually access the `viewport` property
15
+ * directly; view will automatically check the viewport dimensions against the active size classes and activate or deactivate them as needed.
16
+ *
17
+ * The current viewport specification can be obtained by invoking the static `currentVewport()` method.
18
+ */
19
+ export function BMViewport() {} // <constructor>
20
+
21
+ BMViewport.prototype = {
22
+
23
+ /**
24
+ * The width of the viewport.
25
+ */
26
+ _width: undefined, // <Number>
27
+ get width() {
28
+ return this._width;
29
+ },
30
+
31
+ /**
32
+ * The width of the viewport.
33
+ */
34
+ _height: undefined, // <Number>
35
+ get height() {
36
+ return this._height;
37
+ },
38
+
39
+ /**
40
+ * The orientation of the viewport.
41
+ */
42
+ _orientation: undefined, // <BMLayoutOrientation>
43
+ get orientation() {
44
+ return this._orientation;
45
+ },
46
+
47
+ /**
48
+ * The width of the viewport.
49
+ */
50
+ _diagonal: undefined, // <Number>
51
+ get diagonal() {
52
+ return this._diagonal;
53
+ },
54
+
55
+ /**
56
+ * The minimum between the width and the height.
57
+ */
58
+ _smallestDimension: undefined, // <Number>
59
+ get smallestDimension() {
60
+ return this._smallestDimension;
61
+ },
62
+
63
+ /**
64
+ * The surface area, in square pixels.
65
+ */
66
+ _surfaceArea: undefined, // <Number>
67
+ get surfaceArea() {
68
+ return this._surfaceArea;
69
+ },
70
+
71
+ _measurements: undefined, // <Dictionary<AnyObject>>
72
+
73
+ /**
74
+ * Designated initializer, invoked immediately after any viewport
75
+ * is constructed.
76
+ */
77
+ init() {
78
+ this._measurements = {};
79
+ },
80
+
81
+ /**
82
+ * This method is automatically invoked by CoreUI when this viewport is tested against a
83
+ * size class and there is no cached result.
84
+ * Tests whether this viewport matches the given size class and computes its match
85
+ * priority, then caches the result for easier retrieval in subsequent comparations.
86
+ * @param sizeClass <BMLayoutSizeClass> The size class to test against.
87
+ */
88
+ _measureCompatibilityWithSizeClass(sizeClass) {
89
+ let measurement = {};
90
+
91
+ let matches = YES;
92
+
93
+ // Check that the width matches
94
+ if (sizeClass._maximumWidth && this._width > sizeClass._maximumWidth) {
95
+ matches = NO;
96
+ }
97
+
98
+ // The height
99
+ if (sizeClass._maximumHeight && this._height > sizeClass._maximumHeight) {
100
+ matches = NO;
101
+ }
102
+
103
+ // The diagonal
104
+ if (sizeClass._maximumDiagonal && this._diagonal > sizeClass._maximumDiagonal) {
105
+ matches = NO;
106
+ }
107
+
108
+ if (sizeClass._maximumSurfaceArea && this._surfaceArea > sizeClass._maximumSurfaceArea) {
109
+ matches = NO;
110
+ }
111
+
112
+ // And the orientation
113
+ if (sizeClass._orientation != BMLayoutOrientation.Any && this._orientation != sizeClass._orientation) {
114
+ matches = NO;
115
+ }
116
+
117
+ measurement.matches = matches;
118
+
119
+ if (!matches) {
120
+ measurement.matchPriority = 0;
121
+ }
122
+ else {
123
+
124
+ let priorities = [];
125
+
126
+
127
+ // Compute the individual priorities of width, height and diagonal
128
+ if (sizeClass._maximumWidth) {
129
+ priorities.push(sizeClass._maximumWidth / this._width);
130
+ }
131
+
132
+ if (sizeClass._maximumHeight) {
133
+ priorities.push(sizeClass._maximumHeight / this._height);
134
+ }
135
+
136
+ if (sizeClass._maximumDiagonal) {
137
+ priorities.push(sizeClass._maximumDiagonal / this._diagonal);
138
+ }
139
+
140
+ if (sizeClass._maximumSurfaceArea) {
141
+ priorities.push(sizeClass._maximumSurfaceArea / this._surfaceArea);
142
+ }
143
+
144
+ // If no numeric priorities have been computed, the size class is an orientation constraint
145
+ // which currently defaults to a priority of 2
146
+ if (!priorities.length) {
147
+ measurement.matchPriority = 2;
148
+ }
149
+ else {
150
+ // The final priority is the average of the individual priorities
151
+ measurement.matchPriority = priorities.reduce((sum, value) => sum + value) / priorities.length;
152
+ }
153
+ }
154
+
155
+ this._measurements[sizeClass._hashString] = measurement;
156
+
157
+ },
158
+
159
+ /**
160
+ * Tests whether this viewport matches the given size class.
161
+ * @param sizeClass <BMLayoutSizeClass> The size class to check against.
162
+ * @return <Boolean> `YES` if the viewport matches the given size class, `NO` otherwise.
163
+ */
164
+ matchesSizeClass(sizeClass) {
165
+ // Retrieve the cached comparation if it exists, otherwise perform and cache
166
+ // the comparation then return its result
167
+ if (!this._measurements[sizeClass._hashString]) {
168
+ this._measureCompatibilityWithSizeClass(sizeClass);
169
+ }
170
+
171
+ return this._measurements[sizeClass._hashString].matches;
172
+ },
173
+
174
+ /**
175
+ * Returns a number that represents how closely this viewport matches the given size class.
176
+ * Lower numbers indicate a greater priority, with `1` being an exact match,
177
+ * while `0` indicates that this viewport does not match the size class.
178
+ *
179
+ * This value is used by CoreUI to determine the order in which to apply constraint variations
180
+ * when multiple size classes match the current viewport. If several size classes have the same
181
+ * priority, the order in which the variations are applied is not defined.
182
+ * @param sizeClass <BMLayoutSizeClass> The size class to check against.
183
+ * @return <Number> The matching priority.
184
+ */
185
+ matchPriorityForSizeClass(sizeClass) {
186
+ // Retrieve the cached priority if it exists, otherwise compute and cache
187
+ // the priority then return its result
188
+ if (!this._measurements[sizeClass._hashString]) {
189
+ this._measureCompatibilityWithSizeClass(sizeClass);
190
+ }
191
+
192
+ return this._measurements[sizeClass._hashString].matchPriority;
193
+ },
194
+
195
+ /**
196
+ * Tests whether this viewport is identical to the given viewport.
197
+ * @param viewport <BMViewport> The viewport to check against.
198
+ * @return <Boolean> `YES` if the viewports are identical, `NO` otherwise.
199
+ */
200
+ isEqualToViewport(viewport) {
201
+ // It is sufficient to just check the width and height; the other properties are derived from these two values.
202
+ return (this._width == viewport._width) && (this._height == viewport._height);
203
+ }
204
+
205
+ }
206
+
207
+ /**
208
+ * Returns a viewport object that matches the current viewport.
209
+ */
210
+ BMViewport.currentViewport = function () {
211
+ let viewport = new BMViewport;
212
+ viewport.init();
213
+ viewport._width = window.innerWidth;
214
+ viewport._height = window.innerHeight;
215
+ viewport._diagonal = Math.sqrt(Math.pow(window.innerWidth, 2) + Math.pow(window.innerHeight, 2));
216
+ viewport._orientation = viewport._width >= viewport._height ? BMLayoutOrientation.Landscape : BMLayoutOrientation.Portrait;
217
+ viewport._surfaceArea = window.innerWidth * window.innerHeight;
218
+ return viewport;
219
+ }
220
+
221
+ // @endtype