@breakside/jskit 2021.36.1 → 2021.40.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 (106) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  3. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  4. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  5. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  6. package/Frameworks/Foundation.jsframework/JS/JSColor+HTML.js +11 -2
  7. package/Frameworks/Foundation.jsframework/JS/JSColor.js +62 -26
  8. package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +209 -1
  9. package/Frameworks/Foundation.jsframework/JS/JSImage.js +9 -3
  10. package/Frameworks/Foundation.jsframework/JS/JSSpec.js +1 -1
  11. package/Frameworks/Foundation.jsframework/JS/JSURL.js +42 -3
  12. package/Frameworks/Foundation.jsframework/JS/JSURLRequest.js +4 -1
  13. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  14. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  15. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  16. package/Info.json +2 -2
  17. package/Node/io.breakside.jskit-bundle.js +4 -4
  18. package/Resources/doc-default.css +86 -0
  19. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  20. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  21. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  22. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  23. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  24. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  25. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  26. package/Root/Frameworks/DOM/Info.yaml +1 -1
  27. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  28. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  29. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  30. package/Root/Frameworks/Foundation/JSColor+HTML.js +11 -2
  31. package/Root/Frameworks/Foundation/JSColor.js +62 -26
  32. package/Root/Frameworks/Foundation/JSColorSpace.js +209 -1
  33. package/Root/Frameworks/Foundation/JSImage.js +9 -3
  34. package/Root/Frameworks/Foundation/JSSpec.js +1 -1
  35. package/Root/Frameworks/Foundation/JSURL.js +42 -3
  36. package/Root/Frameworks/Foundation/JSURLRequest.js +4 -1
  37. package/Root/Frameworks/ImageKit/IKHTMLCanvasBitmapContext.js +1 -1
  38. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  39. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  40. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  41. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  42. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  43. package/Root/Frameworks/PDFKit/PDFColorSpace.js +1 -1
  44. package/Root/Frameworks/PDFKit/PDFReader.js +8 -3
  45. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  46. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  47. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  48. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  49. package/Root/Frameworks/ServerKit/SKValidatingObject.js +21 -0
  50. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  51. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  52. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  53. package/Root/Frameworks/UIKit/JSColor+UIKit.js +75 -0
  54. package/Root/Frameworks/UIKit/UIAccessibility.js +15 -0
  55. package/Root/Frameworks/UIKit/UIActivityIndicatorView.js +2 -1
  56. package/Root/Frameworks/UIKit/UIAlertController.js +4 -3
  57. package/Root/Frameworks/UIKit/UIAnimation.js +7 -13
  58. package/Root/Frameworks/UIKit/UIApplication.js +3 -0
  59. package/Root/Frameworks/UIKit/UIBasicAnimation.js +6 -0
  60. package/Root/Frameworks/UIKit/UIButton.js +49 -26
  61. package/Root/Frameworks/UIKit/UICheckbox.js +11 -22
  62. package/Root/Frameworks/UIKit/UIColorPanel.js +29 -15
  63. package/Root/Frameworks/UIKit/UIColorSpace.js +132 -0
  64. package/Root/Frameworks/UIKit/UIColorWell.js +30 -4
  65. package/Root/Frameworks/UIKit/UIControl.js +8 -4
  66. package/Root/Frameworks/UIKit/UIHTMLDisplayServer.js +1 -5
  67. package/Root/Frameworks/UIKit/UIHTMLTextField.js +3 -15
  68. package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +72 -1
  69. package/Root/Frameworks/UIKit/UIImageView.js +4 -0
  70. package/Root/Frameworks/UIKit/UIKit.js +2 -0
  71. package/Root/Frameworks/UIKit/UILabel.js +14 -2
  72. package/Root/Frameworks/UIKit/UILayer.js +29 -1
  73. package/Root/Frameworks/UIKit/UIListView.js +23 -12
  74. package/Root/Frameworks/UIKit/UIListViewCell.js +10 -2
  75. package/Root/Frameworks/UIKit/UIMenu.js +21 -13
  76. package/Root/Frameworks/UIKit/UIMenuBar.js +5 -4
  77. package/Root/Frameworks/UIKit/UIMenuView.js +9 -5
  78. package/Root/Frameworks/UIKit/UINavigationBar.js +8 -5
  79. package/Root/Frameworks/UIKit/UINavigationController.js +3 -2
  80. package/Root/Frameworks/UIKit/UIOutlineViewCell.js +2 -1
  81. package/Root/Frameworks/UIKit/UIPopupButton.js +22 -25
  82. package/Root/Frameworks/UIKit/UIPopupWindow.js +9 -2
  83. package/Root/Frameworks/UIKit/UIProgressIndicatorView.js +1 -1
  84. package/Root/Frameworks/UIKit/UIRadioGroup.js +11 -22
  85. package/Root/Frameworks/UIKit/UIScroller.js +4 -3
  86. package/Root/Frameworks/UIKit/UISegmentedControl.js +16 -15
  87. package/Root/Frameworks/UIKit/UISlider.js +29 -37
  88. package/Root/Frameworks/UIKit/UISplitView.js +16 -0
  89. package/Root/Frameworks/UIKit/UITabView.js +34 -31
  90. package/Root/Frameworks/UIKit/UITextEditor.js +2 -1
  91. package/Root/Frameworks/UIKit/UITextField.js +13 -14
  92. package/Root/Frameworks/UIKit/UITextLayer.js +5 -0
  93. package/Root/Frameworks/UIKit/UITokenField.js +3 -3
  94. package/Root/Frameworks/UIKit/UIToolbar.js +84 -38
  95. package/Root/Frameworks/UIKit/UIToolbarOverflow.svg +8 -0
  96. package/Root/Frameworks/UIKit/UITooltipWindow.js +38 -15
  97. package/Root/Frameworks/UIKit/UITraitCollection.js +21 -0
  98. package/Root/Frameworks/UIKit/UIUserInterface.js +6 -0
  99. package/Root/Frameworks/UIKit/UIWebView.js +3 -2
  100. package/Root/Frameworks/UIKit/UIWindow.js +178 -52
  101. package/Root/Frameworks/UIKit/UIWindowButtonCloseInactive.svg +1 -1
  102. package/Root/Frameworks/UIKit/UIWindowButtonCloseNormal.svg +1 -1
  103. package/Root/Frameworks/UIKit/UIWindowServer.js +72 -9
  104. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  105. package/Root/Templates/html/${PROJECT_NAME}/www/index.html +24 -4
  106. package/package.json +1 -1
@@ -1,3 +1,18 @@
1
+ // Copyright 2020 Breakside Inc.
2
+ //
3
+ // Licensed under the Breakside Public License, Version 1.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // If a copy of the License was not distributed with this file, you may
6
+ // obtain a copy at
7
+ //
8
+ // http://breakside.io/licenses/LICENSE-1.0.txt
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
1
16
  // #import Foundation
2
17
  'use strict';
3
18
 
@@ -16,6 +16,7 @@
16
16
  // #import "UIView.js"
17
17
  // #import "UICustomAnimation.js"
18
18
  // #import "UIImageLayer.js"
19
+ // #import "JSColor+UIKit.js"
19
20
  'use strict';
20
21
 
21
22
  (function(){
@@ -190,7 +191,7 @@ UIActivityIndicatorView.Style = {
190
191
  light: 1
191
192
  };
192
193
 
193
- var darkColor = JSColor.black;
194
+ var darkColor = JSColor.initWithUIStyles(JSColor.black, JSColor.white);
194
195
  var lightColor = JSColor.white;
195
196
 
196
197
  var images = Object.create({}, {
@@ -19,6 +19,7 @@
19
19
  // #import "UIButton.js"
20
20
  // #import "UIPopupWindow.js"
21
21
  // #import "UIAlertAction.js"
22
+ // #import "JSColor+UIKit.js"
22
23
  'use strict';
23
24
 
24
25
  (function(){
@@ -214,9 +215,9 @@ UIAlertController.ButtonStylers = Object.create({}, {
214
215
  get: function(){
215
216
  var styler = UIButtonDefaultStyler.init();
216
217
  styler.font = styler.font.fontWithPointSize(JSFont.Size.detail).fontWithWeight(JSFont.Weight.bold);
217
- styler.normalTitleColor = JSColor.initWithRGBA(204/255,0,0);
218
- styler.activeTitleColor = styler.normalTitleColor.colorDarkenedByPercentage(0.2);
219
- styler.disabledTitleColor = styler.normalTitleColor.colorWithAlpha(0.5);
218
+ styler.normalTitleColor = JSColor.destructive;
219
+ styler.activeTitleColor = JSColor.destructive.colorDarkenedByPercentage(0.2);
220
+ styler.disabledTitleColor = JSColor.destructive.colorWithAlpha(0.5);
220
221
  Object.defineProperty(this, 'destructive', {writable: true, value: styler});
221
222
  return styler;
222
223
  },
@@ -96,19 +96,7 @@ UIAnimation.interpolationForValues = function(from, to){
96
96
  return UIAnimation.interpolateAffineTransform;
97
97
  }
98
98
  if (from.isKindOfClass && from.isKindOfClass(JSColor)){
99
- if (from.components.length == 1){
100
- return UIAnimation.interpolate1Color;
101
- }
102
- if (from.components.length == 2){
103
- return UIAnimation.interpolate2Color;
104
- }
105
- if (from.components.length == 3){
106
- return UIAnimation.interpolate3Color;
107
- }
108
- if (from.components.length == 4){
109
- return UIAnimation.interpolate4Color;
110
- }
111
- return UIAnimation.interpolateNull;
99
+ return UIAnimation.interpolateColor;
112
100
  }
113
101
  if (from.animationInterpolation){
114
102
  return from.animationInterpolation;
@@ -158,6 +146,12 @@ UIAnimation.interpolateAffineTransform = function(from, to, progress){
158
146
  );
159
147
  };
160
148
 
149
+ UIAnimation.interpolateColor = function(from, to, progress){
150
+ var mixed = from.space.mixedComponents(from.components, to.components, progress);
151
+ mixed.push(from.components[from.space.numberOfComponents] + (to.components[to.space.numberOfComponents] - from.components[from.space.numberOfComponents]) * progress);
152
+ return JSColor.initWithSpaceAndComponents(from.space, mixed);
153
+ };
154
+
161
155
  UIAnimation.interpolate1Color = function(from, to, progress){
162
156
  return JSColor.initWithSpaceAndComponents(from.space, [
163
157
  from.components[0] + (to.components[0] - from.components[0]) * progress
@@ -37,6 +37,9 @@ JSClass('UIApplication', UIResponder, {
37
37
  logger.info("Creating application");
38
38
  shared = this;
39
39
  this.windowServer = windowServer;
40
+ if (this.bundle.info.UIUserInterfaceStyle === "light"){
41
+ this.windowServer.darkModeEnabled = false;
42
+ }
40
43
  this._windows = [];
41
44
  this.windowServer.postNotificationForAccessibilityElement(UIAccessibility.Notification.elementCreated, this);
42
45
  },
@@ -97,6 +97,12 @@ JSClass('UIBasicAnimation', UIPropertyAnimation, {
97
97
  if (this._toValue === null){
98
98
  this._toValue = JSResolveDottedName(this.layer.model, this.keyPath);
99
99
  }
100
+ if ((this._fromValue instanceof JSColor) && (this._toValue instanceof JSColor)){
101
+ if (this._fromValue.space !== this._toValue.space || !this._fromValue.space.canMixComponents){
102
+ this._fromValue = this._fromValue.rgbaColor();
103
+ this._toValue = this._toValue.rgbaColor();
104
+ }
105
+ }
100
106
  return UIAnimation.interpolationForValues(this._fromValue, this._toValue);
101
107
  }
102
108
 
@@ -17,6 +17,7 @@
17
17
  // #import "UILabel.js"
18
18
  // #import "UIImageView.js"
19
19
  // #import "UIEvent.js"
20
+ // #import "JSColor+UIKit.js"
20
21
  'use strict';
21
22
 
22
23
  JSClass("UIButton", UIControl, {
@@ -29,7 +30,7 @@ JSClass("UIButton", UIControl, {
29
30
  _imagesByState: null,
30
31
  _backgroundImagesByState: null,
31
32
 
32
- _imageView: null,
33
+ imageView: JSLazyInitProperty('_createImageView', '_imageView'),
33
34
  _backgroundImageView: null,
34
35
 
35
36
  initWithSpec: function(spec){
@@ -404,7 +405,8 @@ JSClass("UIButtonStyler", UIControlStyler, {
404
405
  size.width += titleSize.width;
405
406
  }
406
407
  }else if (image !== null){
407
- size.width += image.size.width;
408
+ imageScale = contentHeight / image.size.height;
409
+ size.width += Math.ceil(image.size.width * imageScale);
408
410
  }
409
411
  return size;
410
412
  }
@@ -420,7 +422,9 @@ JSClass("UIButtonStyler", UIControlStyler, {
420
422
  size.height += titleSize.height;
421
423
  }
422
424
  }else if (image !== null){
423
- size.width += image.size.width;
425
+ contentHeight = image.size.height;
426
+ imageScale = contentHeight / image.size.height;
427
+ size.width += Math.ceil(image.size.width * imageScale);
424
428
  size.height += image.size.height;
425
429
  }
426
430
  return size;
@@ -472,9 +476,11 @@ JSClass("UIButtonCustomStyler", UIButtonStyler, {
472
476
 
473
477
  normalBackgroundColor: null,
474
478
  disabledBackgroundColor: null,
479
+ overBackgroundColor: null,
475
480
  activeBackgroundColor: null,
476
481
  normalTitleColor: null,
477
482
  disabledTitleColor: null,
483
+ overTitleColor: null,
478
484
  activeTitleColor: null,
479
485
  cornerRadius: 0,
480
486
 
@@ -493,7 +499,7 @@ JSClass("UIButtonCustomStyler", UIButtonStyler, {
493
499
 
494
500
  init: function(){
495
501
  UIButtonCustomStyler.$super.init.call(this);
496
- this.initWithColor(JSColor.black);
502
+ this.initWithColor(JSColor.text);
497
503
  },
498
504
 
499
505
  initWithSpec: function(spec){
@@ -501,9 +507,27 @@ JSClass("UIButtonCustomStyler", UIButtonStyler, {
501
507
  if (spec.containsKey('normalBackgroundColor')){
502
508
  this.normalBackgroundColor = spec.valueForKey("normalBackgroundColor", JSColor);
503
509
  }
510
+ if (spec.containsKey('activeBackgroundColor')){
511
+ this.activeBackgroundColor = spec.valueForKey("activeBackgroundColor", JSColor);
512
+ }
513
+ if (spec.containsKey('disabledBackgroundColor')){
514
+ this.disabledBackgroundColor = spec.valueForKey("disabledBackgroundColor", JSColor);
515
+ }
516
+ if (spec.containsKey('overBackgroundColor')){
517
+ this.overBackgroundColor = spec.valueForKey("overBackgroundColor", JSColor);
518
+ }
504
519
  if (spec.containsKey('normalTitleColor')){
505
520
  this.normalTitleColor = spec.valueForKey("normalTitleColor", JSColor);
506
521
  }
522
+ if (spec.containsKey('activeTitleColor')){
523
+ this.activeTitleColor = spec.valueForKey("activeTitleColor", JSColor);
524
+ }
525
+ if (spec.containsKey('disabledTitleColor')){
526
+ this.disabledTitleColor = spec.valueForKey("disabledTitleColor", JSColor);
527
+ }
528
+ if (spec.containsKey('overTitleColor')){
529
+ this.overTitleColor = spec.valueForKey("overTitleColor", JSColor);
530
+ }
507
531
  if (spec.containsKey('cornerRadius')){
508
532
  this.cornerRadius = spec.valueForKey("cornerRadius");
509
533
  }
@@ -517,6 +541,9 @@ JSClass("UIButtonCustomStyler", UIButtonStyler, {
517
541
  if (this.disabledTitleColor === null){
518
542
  this.disabledTitleColor = this.normalTitleColor.colorWithAlpha(0.5);
519
543
  }
544
+ if (this.overTitleColor === null){
545
+ this.overTitleColor = this.normalTitleColor;
546
+ }
520
547
  if (this.normalBackgroundColor !== null){
521
548
  if (this.activeBackgroundColor === null){
522
549
  this.activeBackgroundColor = this.normalBackgroundColor.colorDarkenedByPercentage(0.2);
@@ -551,6 +578,14 @@ JSClass("UIButtonCustomStyler", UIButtonStyler, {
551
578
  if (button._imageView !== null){
552
579
  button._imageView.templateColor = this.activeTitleColor;
553
580
  }
581
+ }else if (button.over){
582
+ button.layer.backgroundColor = this.overBackgroundColor;
583
+ if (button._titleLabel !== null){
584
+ button._titleLabel.textColor = this.overTitleColor;
585
+ }
586
+ if (button._imageView !== null){
587
+ button._imageView.templateColor = this.overTitleColor;
588
+ }
554
589
  }else{
555
590
  button.layer.backgroundColor = this.normalBackgroundColor;
556
591
  if (button._titleLabel !== null){
@@ -587,16 +622,16 @@ JSClass("UIButtonDefaultStyler", UIButtonStyler, {
587
622
 
588
623
  init: function(){
589
624
  UIButtonDefaultStyler.$super.init.call(this);
590
- this.normalBackgroundColor = UIButtonDefaultStyler.NormalBackgroundColor;
591
- this.disabledBackgroundColor = UIButtonDefaultStyler.DisabledBackgroundColor;
592
- this.activeBackgroundColor = UIButtonDefaultStyler.ActiveBackgroundColor;
593
- this.normalBorderColor = UIButtonDefaultStyler.NormalBorderColor;
594
- this.disabledBorderColor = UIButtonDefaultStyler.DisabledBorderColor;
595
- this.activeBorderColor = UIButtonDefaultStyler.ActiveBorderColor;
596
- this.normalTitleColor = UIButtonDefaultStyler.NormalTitleColor;
597
- this.disabledTitleColor = UIButtonDefaultStyler.DisabledTitleColor;
598
- this.activeTitleColor = UIButtonDefaultStyler.ActiveTitleColor;
599
- this.shadowColor = JSColor.initWithRGBA(0, 0, 0, 0.1);
625
+ this.normalBackgroundColor = JSColor.controlBackground;
626
+ this.disabledBackgroundColor = JSColor.disabledControlBackground;
627
+ this.activeBackgroundColor = JSColor.activeControlBackground;
628
+ this.normalBorderColor = JSColor.controlBorder;
629
+ this.disabledBorderColor = JSColor.disabledControlBorder;
630
+ this.activeBorderColor = JSColor.activeControlBorder;
631
+ this.normalTitleColor = JSColor.controlTitle;
632
+ this.disabledTitleColor = JSColor.disabledControlTitle;
633
+ this.activeTitleColor = JSColor.activeControlTitle;
634
+ this.shadowColor = JSColor.controlShadow;
600
635
  this.shadowOffset = JSPoint(0, 1);
601
636
  this.titleInsets = JSInsets(3, 7);
602
637
  },
@@ -648,18 +683,6 @@ JSClass("UIButtonDefaultStyler", UIButtonStyler, {
648
683
 
649
684
  });
650
685
 
651
- UIButtonDefaultStyler.NormalBackgroundColor = JSColor.initWithRGBA(250/255,250/255,250/255);
652
- UIButtonDefaultStyler.ActiveBackgroundColor = JSColor.initWithRGBA(224/255,224/255,224/255);
653
- UIButtonDefaultStyler.DisabledBackgroundColor = JSColor.initWithRGBA(240/255,240/255,240/255);
654
-
655
- UIButtonDefaultStyler.NormalBorderColor = JSColor.initWithRGBA(204/255,204/255,204/255);
656
- UIButtonDefaultStyler.ActiveBorderColor = JSColor.initWithRGBA(192/255,192/255,192/255);
657
- UIButtonDefaultStyler.DisabledBorderColor = JSColor.initWithRGBA(224/255,224/255,224/255);
658
-
659
- UIButtonDefaultStyler.NormalTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
660
- UIButtonDefaultStyler.ActiveTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
661
- UIButtonDefaultStyler.DisabledTitleColor = JSColor.initWithRGBA(152/255,152/255,152/255);
662
-
663
686
  JSClass("UIButtonImageStyler", UIButtonStyler, {
664
687
 
665
688
  color: JSDynamicProperty('_color', null),
@@ -17,6 +17,7 @@
17
17
  // #import "UILabel.js"
18
18
  // #import "UIImageView.js"
19
19
  // #import "UIEvent.js"
20
+ // #import "JSColor+UIKit.js"
20
21
  'use strict';
21
22
 
22
23
  (function(){
@@ -255,16 +256,16 @@ JSClass("UICheckboxDefaultStyler", UICheckboxStyler, {
255
256
  shadowRadius: 1,
256
257
 
257
258
  init: function(){
258
- this.normalBackgroundColor = UICheckboxDefaultStyler.NormalBackgroundColor;
259
- this.disabledBackgroundColor = UICheckboxDefaultStyler.DisabledBackgroundColor;
260
- this.activeBackgroundColor = UICheckboxDefaultStyler.ActiveBackgroundColor;
261
- this.normalBorderColor = UICheckboxDefaultStyler.NormalBorderColor;
262
- this.disabledBorderColor = UICheckboxDefaultStyler.DisabledBorderColor;
263
- this.activeBorderColor = UICheckboxDefaultStyler.ActiveBorderColor;
264
- this.normalTitleColor = UICheckboxDefaultStyler.NormalTitleColor;
265
- this.disabledTitleColor = UICheckboxDefaultStyler.DisabledTitleColor;
266
- this.activeTitleColor = UICheckboxDefaultStyler.ActiveTitleColor;
267
- this.shadowColor = JSColor.initWithRGBA(0, 0, 0, 0.1);
259
+ this.normalBackgroundColor = JSColor.controlBackground;
260
+ this.disabledBackgroundColor = JSColor.disabledControlBackground;
261
+ this.activeBackgroundColor = JSColor.activeControlBackground;
262
+ this.normalBorderColor = JSColor.controlBorder;
263
+ this.disabledBorderColor = JSColor.disabledControlBorder;
264
+ this.activeBorderColor = JSColor.activeControlBorder;
265
+ this.normalTitleColor = JSColor.controlTitle;
266
+ this.disabledTitleColor = JSColor.disabledControlTitle;
267
+ this.activeTitleColor = JSColor.activeControlTitle;
268
+ this.shadowColor = JSColor.controlShadow;
268
269
  this.shadowOffset = JSPoint(0, 1);
269
270
  },
270
271
 
@@ -344,18 +345,6 @@ JSClass("UICheckboxDefaultStyler", UICheckboxStyler, {
344
345
 
345
346
  });
346
347
 
347
- UICheckboxDefaultStyler.NormalBackgroundColor = JSColor.initWithRGBA(250/255,250/255,250/255);
348
- UICheckboxDefaultStyler.ActiveBackgroundColor = JSColor.initWithRGBA(224/255,224/255,224/255);
349
- UICheckboxDefaultStyler.DisabledBackgroundColor = JSColor.initWithRGBA(240/255,240/255,240/255);
350
-
351
- UICheckboxDefaultStyler.NormalBorderColor = JSColor.initWithRGBA(204/255,204/255,204/255);
352
- UICheckboxDefaultStyler.ActiveBorderColor = JSColor.initWithRGBA(192/255,192/255,192/255);
353
- UICheckboxDefaultStyler.DisabledBorderColor = JSColor.initWithRGBA(224/255,224/255,224/255);
354
-
355
- UICheckboxDefaultStyler.NormalTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
356
- UICheckboxDefaultStyler.ActiveTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
357
- UICheckboxDefaultStyler.DisabledTitleColor = JSColor.initWithRGBA(152/255,152/255,152/255);
358
-
359
348
  var images = Object.create({}, {
360
349
 
361
350
  bundle: {
@@ -1,3 +1,18 @@
1
+ // Copyright 2021 Breakside Inc.
2
+ //
3
+ // Licensed under the Breakside Public License, Version 1.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // If a copy of the License was not distributed with this file, you may
6
+ // obtain a copy at
7
+ //
8
+ // http://breakside.io/licenses/LICENSE-1.0.txt
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
1
16
  // #import "UIPopupWindow.js"
2
17
  // #import "UISlider.js"
3
18
  // #import "UITextField.js"
@@ -13,6 +28,8 @@ JSProtocol("UIColorPanelDelegate", JSProtocol, {
13
28
 
14
29
  JSClass("UIColorPanel", UIPopupWindow, {
15
30
 
31
+ escapeClosesWindow: true,
32
+
16
33
  init: function(){
17
34
  UIColorPanel.$super.init.call(this);
18
35
  this.contentViewController = UIColorPanelViewController.init();
@@ -153,16 +170,13 @@ JSClass("UIColorPanelViewController", UIViewController, {
153
170
  wellStyler.disabledBorderWidth = 0;
154
171
  wellStyler.cornerRadius = 3;
155
172
  var componentStyler = UITextFieldCustomStyler.init();
156
- componentStyler.backgroundColor = JSColor.white.colorWithAlpha(0.4);
157
- componentStyler.activeBackgroundColor = JSColor.white.colorWithAlpha(0.8);
173
+ componentStyler.backgroundColor = JSColor.initWithUIStyles(JSColor.white, JSColor.white.colorWithAlpha(0.1));
158
174
  componentStyler.cornerRadius = 3;
159
175
  componentStyler.textInsets = JSInsets(3, 4);
160
- componentStyler.textColor = JSColor.black;
161
- componentStyler.placeholderColor = JSColor.black.colorWithAlpha(0.4);
176
+ componentStyler.textColor = JSColor.text;
177
+ componentStyler.placeholderColor = JSColor.placeholderText;
162
178
  componentStyler.borderWidth = 1;
163
- componentStyler.borderColor = JSColor.black.colorWithAlpha(0.2);
164
- componentStyler.activeBorderColor = JSColor.black.colorWithAlpha(0.4);
165
- componentStyler.disabledBorderColor = JSColor.black.colorWithAlpha(0.2);
179
+ componentStyler.borderColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.black.colorWithAlpha(0.4));
166
180
  this.saturationBrightnessControl = UIColorPanelTwoAxisSlider.init();
167
181
  this.hueSlider = UISlider.initWithStyler(hueStyler);
168
182
  this.alphaSlider = UISlider.initWithStyler(alphaStyler);
@@ -203,7 +217,7 @@ JSClass("UIColorPanelViewController", UIViewController, {
203
217
  this.hexLabel.text = "Hex";
204
218
  this._updateComponentLabels();
205
219
  this.component4Label.text = "Alpha";
206
- this.hexLabel.textColor = JSColor.initWithWhite(0.5);
220
+ this.hexLabel.textColor = JSColor.text.colorWithAlpha(0.5);
207
221
  this.component1Label.textColor = this.hexLabel.textColor;
208
222
  this.component2Label.textColor = this.hexLabel.textColor;
209
223
  this.component3Label.textColor = this.hexLabel.textColor;
@@ -216,7 +230,7 @@ JSClass("UIColorPanelViewController", UIViewController, {
216
230
 
217
231
  var hashLabel = UILabel.init();
218
232
  hashLabel.font = this.hexField.font;
219
- hashLabel.textColor = JSColor.initWithWhite(0.6);
233
+ hashLabel.textColor = JSColor.text.colorWithAlpha(0.4);
220
234
  hashLabel.text = "#";
221
235
  hashLabel.sizeToFit();
222
236
  this.hexField.leftAccessoryView = hashLabel;
@@ -733,12 +747,12 @@ JSClass("UIColorPanelTwoAxisSlider", UIControl, {
733
747
  this._maximumValue = JSPoint(1, 1);
734
748
  this.knobSize = JSSize(16, 16);
735
749
  this._value = JSPoint(0, 0);
736
- this.normalKnobBackgroundColor = JSColor.white;
737
- this.activeKnobBackgroundColor = JSColor.white;
738
- this.disabledKnobBackgroundColor = this.normalKnobBackgroundColor.colorWithAlpha(0.5);
739
- this.normalKnobBorderColor = JSColor.black.colorWithAlpha(0.2);
740
- this.activeKnobBorderColor = JSColor.black.colorWithAlpha(0.3);
741
- this.disabledKnobBorderColor = JSColor.black.colorWithAlpha(0.1);
750
+ this.normalKnobBackgroundColor = JSColor.controlBackground;
751
+ this.activeKnobBackgroundColor = JSColor.activeControlBackground;
752
+ this.disabledKnobBackgroundColor = JSColor.disabledControlBackground;
753
+ this.normalKnobBorderColor = JSColor.controlBorder;
754
+ this.activeKnobBorderColor = JSColor.activeControlBorder;
755
+ this.disabledKnobBorderColor = JSColor.disabledControlBorder;
742
756
  this.xLayer = UILayer.init();
743
757
  this.yLayer = UILayer.init();
744
758
  this.yLayer.backgroundGradient = JSGradient.initWithColors([JSColor.black, JSColor.black.colorWithAlpha(0)]);
@@ -0,0 +1,132 @@
1
+ // Copyright 2021 Breakside Inc.
2
+ //
3
+ // Licensed under the Breakside Public License, Version 1.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // If a copy of the License was not distributed with this file, you may
6
+ // obtain a copy at
7
+ //
8
+ // http://breakside.io/licenses/LICENSE-1.0.txt
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // #import Foundation
17
+ // #import "UIUserInterface.js"
18
+ /* global UIApplication */
19
+ "use strict";
20
+
21
+ JSClass("UIColorSpace", JSMappedColorSpace, {
22
+
23
+ name: "ui",
24
+ numberOfComponents: 1,
25
+ componentNames: {},
26
+ colors: null,
27
+
28
+ initWithStyles: function(lightColor, darkColor, lightContrastColor, darkContrastColor){
29
+ if (darkColor === undefined){
30
+ darkColor = lightColor;
31
+ }
32
+ if (lightContrastColor === undefined){
33
+ lightContrastColor = lightColor;
34
+ }
35
+ if (darkContrastColor === undefined){
36
+ darkContrastColor = darkColor;
37
+ }
38
+ this.colors = [
39
+ lightColor,
40
+ darkColor,
41
+ lightContrastColor,
42
+ darkContrastColor
43
+ ];
44
+ },
45
+
46
+ colorFromComponents: function(components){
47
+ var color = this.colors[UIColorSpace.colorIndex];
48
+ if (components[0] < 1){
49
+ color = color.colorDarkenedByPercentage(1 - components[0]);
50
+ }else if (components[0] > 1){
51
+ color = color.colorLightenedByPercentage(components[0] - 1);
52
+ }
53
+ return color;
54
+ },
55
+
56
+ componentsDarkenedByPercentage: function(components, percentage){
57
+ return [
58
+ components[0] * (1.0 - percentage)
59
+ ];
60
+ },
61
+
62
+ componentsLightenedByPercentage: function(components, percentage){
63
+ return [
64
+ components[0] * (1.0 + percentage)
65
+ ];
66
+ }
67
+
68
+ });
69
+
70
+ UIColorSpace.colorIndex = 0;
71
+
72
+ UIColorSpace.setTraitCollection = function(traitCollection){
73
+ if (traitCollection.accessibilityContrast === UIUserInterface.Contrast.high){
74
+ if (traitCollection.userInterfaceStyle === UIUserInterface.Style.dark){
75
+ UIColorSpace.colorIndex = 3;
76
+ }else{
77
+ UIColorSpace.colorIndex = 2;
78
+ }
79
+ }else{
80
+ if (traitCollection.userInterfaceStyle === UIUserInterface.Style.dark){
81
+ UIColorSpace.colorIndex = 1;
82
+ }else{
83
+ UIColorSpace.colorIndex = 0;
84
+ }
85
+ }
86
+ if (JSColor.invalidateCSSCache){
87
+ JSColor.invalidateCSSCache();
88
+ }
89
+ };
90
+
91
+ JSClass("UINamedColorSpace", JSNamedColorSpace, {
92
+
93
+ setColorForName: function(name, color){
94
+ var namedColor = UINamedColorSpace.$super.setColorForName.call(this, name, color);
95
+ if (JSGlobalObject.UIApplication && UIApplication.shared){
96
+ UIApplication.shared.windowServer.setNeedsRedisplay();
97
+ if (JSColor.invalidateCSSCache){
98
+ JSColor.invalidateCSSCache();
99
+ }
100
+ }
101
+ var space = this;
102
+ Object.defineProperty(JSColor, name, {
103
+ configurable: true,
104
+ get: function(){
105
+ return namedColor;
106
+ },
107
+ set: function(color){
108
+ space.setColorForName(name, color);
109
+ }
110
+ });
111
+ return namedColor;
112
+ },
113
+
114
+ setStylesForName: function(name, lightColor, darkColor, lightContrastColor, darkContrastColor){
115
+ var color = JSColor.initWithUIStyles(lightColor, darkColor, lightContrastColor, darkContrastColor);
116
+ this.setColorForName(name, color);
117
+ }
118
+
119
+ });
120
+
121
+ Object.defineProperties(JSColorSpace, {
122
+
123
+ ui: {
124
+ configurable: true,
125
+ get: function(){
126
+ var space = UINamedColorSpace.init();
127
+ Object.defineProperty(this, "ui", {value: space});
128
+ return space;
129
+ }
130
+ }
131
+
132
+ });
@@ -1,3 +1,18 @@
1
+ // Copyright 2021 Breakside Inc.
2
+ //
3
+ // Licensed under the Breakside Public License, Version 1.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // If a copy of the License was not distributed with this file, you may
6
+ // obtain a copy at
7
+ //
8
+ // http://breakside.io/licenses/LICENSE-1.0.txt
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
1
16
  // #import "UIControl.js"
2
17
  // #import "UIPasteboard.js"
3
18
  // #import "UIColorPanel.js"
@@ -12,11 +27,12 @@ JSClass("UIColorWell", UIControl, {
12
27
  initWithSpec: function(spec){
13
28
  UIColorWell.$super.initWithSpec.call(this, spec);
14
29
  if (spec.containsKey("color")){
15
- this._color = spec.valueForKey("color", JSColor);
30
+ this._color = spec.valueForKey("color", JSColor).rgbaColor();
16
31
  }
17
32
  if (spec.containsKey("allowsAlpha")){
18
- this._allowsAlpha = spec.valueForKey("allowsAlpha", JSColor);
33
+ this.allowsAlpha = spec.valueForKey("allowsAlpha", JSColor);
19
34
  }
35
+ this.update();
20
36
  },
21
37
 
22
38
  commonUIControlInit: function(){
@@ -36,14 +52,14 @@ JSClass("UIColorWell", UIControl, {
36
52
  color: JSDynamicProperty("_color", JSColor.black),
37
53
 
38
54
  setColor: function(color){
39
- this._color = color;
55
+ this._color = color.rgbaColor();
40
56
  this.update();
41
57
  },
42
58
 
43
59
  _changeColor: function(color){
44
60
  this.color = color;
45
- this.sendActionsForEvents(UIControl.Event.valueChanged);
46
61
  this.didChangeValueForBinding('color');
62
+ this.sendActionsForEvents(UIControl.Event.valueChanged);
47
63
  },
48
64
 
49
65
  // ----------------------------------------------------------------------
@@ -288,15 +304,23 @@ JSClass("UIColorWellDefaultStyler", UIColorWellStyler, {
288
304
  }
289
305
  if (spec.containsKey("normalBorderColor")){
290
306
  this.normalBorderColor = spec.valueForKey("normalBorderColor", JSColor);
307
+ }else{
308
+ this.normalBorderColor = JSColor.black.colorWithAlpha(0.2);
291
309
  }
292
310
  if (spec.containsKey("activeBorderColor")){
293
311
  this.activeBorderColor = spec.valueForKey("activeBorderColor", JSColor);
312
+ }else{
313
+ this.activeBorderColor = JSColor.black.colorWithAlpha(0.4);
294
314
  }
295
315
  if (spec.containsKey("dropTargetBorderColor")){
296
316
  this.dropTargetBorderColor = spec.valueForKey("dropTargetBorderColor", JSColor);
317
+ }else{
318
+ this.dropTargetBorderColor = JSColor.black.colorWithAlpha(0.2);
297
319
  }
298
320
  if (spec.containsKey("disabledBorderColor")){
299
321
  this.disabledBorderColor = spec.valueForKey("disabledBorderColor", JSColor);
322
+ }else{
323
+ this.disabledBorderColor = JSColor.clear;
300
324
  }
301
325
  if (spec.containsKey("normalBorderWidth")){
302
326
  this.normalBorderWidth = spec.valueForKey("normalBorderWidth");
@@ -325,6 +349,8 @@ JSClass("UIColorWellDefaultStyler", UIColorWellStyler, {
325
349
  }
326
350
  if (spec.containsKey("wellInnerShadowColor")){
327
351
  this.wellInnerShadowColor = spec.valueForKey("wellInnerShadowColor", JSColor);
352
+ }else{
353
+ this.wellInnerShadowColor = JSColor.black.colorWithAlpha(0.4);
328
354
  }
329
355
  if (spec.containsKey("wellInnerShadowOffset")){
330
356
  this.wellInnerShadowOffset = spec.valueForKey("wellInnerShadowOffset", JSPoint);
@@ -43,10 +43,14 @@ JSClass("UIControl", UIView, {
43
43
  var target;
44
44
  var action;
45
45
  var event;
46
- if (spec.containsKey('target') && spec.containsKey('action')){
47
- target = spec.valueForKey("target");
46
+ if (spec.containsKey('action')){
47
+ if (spec.containsKey("target")){
48
+ target = spec.valueForKey("target");
49
+ }else{
50
+ target = null;
51
+ }
48
52
  action = spec.valueForKey("action");
49
- if (!target.isKindOfClass(UIResponder)){
53
+ if (target !== null && !target.isKindOfClass(UIResponder)){
50
54
  throw new Error("Action target must be a UIResponder: %s.%s".sprintf(spec.unmodifiedValueForKey("target"), spec.unmodifiedValueForKey("action")));
51
55
  }
52
56
  this.addAction(action, target);
@@ -267,7 +271,7 @@ JSClass("UIControl", UIView, {
267
271
  },
268
272
 
269
273
  setOver: function(isOver){
270
- this.toggleStates(UIControl.State.over, isOver);
274
+ this.toggleStates(UIControl.State.over, isOver && this.hasOverState);
271
275
  },
272
276
 
273
277
  isActive: function(){