renalware-core 2.0.160 → 2.0.161

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50ba71bf73d49732a3e9be7cb75ef7267527b6af48cd3362794a21316dfbdfd
4
- data.tar.gz: ad609dc32dc6d6e472089b5dc30dda67b8cfd17857e9f310d0e54c93c7d1a1ac
3
+ metadata.gz: 0bc096586b16fb31366d250f5e89808e021822a56fed19237530c6abd9cbf0dd
4
+ data.tar.gz: 61359de738b4d48c4c4e301d8ff7e5a421aad80258e26387b86bbd525ee62f2d
5
5
  SHA512:
6
- metadata.gz: e9db000533a7a9c8ef8b7042f40f25fdece027d809c94edb09064225c0a89e101b992cde7054e2902853f044e8c987f65c8e588b1957c61d7569b738ad170382
7
- data.tar.gz: bd0ad2bf21e7b0369e8f6ff760e5669368fb3cf852387c6ea6c8d364c4c5d33b20e3ad0ea6094fee14bdedce44b6b2f58d2a59327cca6066542122b73de6ba2d
6
+ metadata.gz: cafb016f3c443c10cddc2b1db2fd469f60b98bd0ad266350758e9e94127e9e8c036dcba451b415bb3497eb7eed28d12f848c2b153d4c2d6c1c42cc0bc78135df
7
+ data.tar.gz: 712f000b0e02727277097de9fa11f76966ca0163bcbf731e330dd4adee5a1d495044c2794a6a81defbdd44369e67c6ced3fc9b139bd920e3346017627ce59dcb
@@ -1910,16 +1910,17 @@ if (window.MutationObserver) {
1910
1910
  }
1911
1911
 
1912
1912
  var EventListener = function() {
1913
- function EventListener(eventTarget, eventName) {
1913
+ function EventListener(eventTarget, eventName, eventOptions) {
1914
1914
  this.eventTarget = eventTarget;
1915
1915
  this.eventName = eventName;
1916
+ this.eventOptions = eventOptions;
1916
1917
  this.unorderedBindings = new Set();
1917
1918
  }
1918
1919
  EventListener.prototype.connect = function() {
1919
- this.eventTarget.addEventListener(this.eventName, this, false);
1920
+ this.eventTarget.addEventListener(this.eventName, this, this.eventOptions);
1920
1921
  };
1921
1922
  EventListener.prototype.disconnect = function() {
1922
- this.eventTarget.removeEventListener(this.eventName, this, false);
1923
+ this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions);
1923
1924
  };
1924
1925
  EventListener.prototype.bindingConnected = function(binding) {
1925
1926
  this.unorderedBindings.add(binding);
@@ -1945,7 +1946,7 @@ var EventListener = function() {
1945
1946
  return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;
1946
1947
  });
1947
1948
  },
1948
- enumerable: true,
1949
+ enumerable: false,
1949
1950
  configurable: true
1950
1951
  });
1951
1952
  return EventListener;
@@ -1994,7 +1995,7 @@ var Dispatcher = function() {
1994
1995
  return listeners.concat(Array.from(map.values()));
1995
1996
  }, []);
1996
1997
  },
1997
- enumerable: true,
1998
+ enumerable: false,
1998
1999
  configurable: true
1999
2000
  });
2000
2001
  Dispatcher.prototype.bindingConnected = function(binding) {
@@ -2010,20 +2011,21 @@ var Dispatcher = function() {
2010
2011
  this.application.handleError(error, "Error " + message, detail);
2011
2012
  };
2012
2013
  Dispatcher.prototype.fetchEventListenerForBinding = function(binding) {
2013
- var eventTarget = binding.eventTarget, eventName = binding.eventName;
2014
- return this.fetchEventListener(eventTarget, eventName);
2014
+ var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions;
2015
+ return this.fetchEventListener(eventTarget, eventName, eventOptions);
2015
2016
  };
2016
- Dispatcher.prototype.fetchEventListener = function(eventTarget, eventName) {
2017
+ Dispatcher.prototype.fetchEventListener = function(eventTarget, eventName, eventOptions) {
2017
2018
  var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
2018
- var eventListener = eventListenerMap.get(eventName);
2019
+ var cacheKey = this.cacheKey(eventName, eventOptions);
2020
+ var eventListener = eventListenerMap.get(cacheKey);
2019
2021
  if (!eventListener) {
2020
- eventListener = this.createEventListener(eventTarget, eventName);
2021
- eventListenerMap.set(eventName, eventListener);
2022
+ eventListener = this.createEventListener(eventTarget, eventName, eventOptions);
2023
+ eventListenerMap.set(cacheKey, eventListener);
2022
2024
  }
2023
2025
  return eventListener;
2024
2026
  };
2025
- Dispatcher.prototype.createEventListener = function(eventTarget, eventName) {
2026
- var eventListener = new EventListener(eventTarget, eventName);
2027
+ Dispatcher.prototype.createEventListener = function(eventTarget, eventName, eventOptions) {
2028
+ var eventListener = new EventListener(eventTarget, eventName, eventOptions);
2027
2029
  if (this.started) {
2028
2030
  eventListener.connect();
2029
2031
  }
@@ -2037,17 +2039,25 @@ var Dispatcher = function() {
2037
2039
  }
2038
2040
  return eventListenerMap;
2039
2041
  };
2042
+ Dispatcher.prototype.cacheKey = function(eventName, eventOptions) {
2043
+ var parts = [ eventName ];
2044
+ Object.keys(eventOptions).sort().forEach(function(key) {
2045
+ parts.push("" + (eventOptions[key] ? "" : "!") + key);
2046
+ });
2047
+ return parts.join(":");
2048
+ };
2040
2049
  return Dispatcher;
2041
2050
  }();
2042
2051
 
2043
- var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#(.+))?$/;
2052
+ var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/;
2044
2053
 
2045
- function parseDescriptorString(descriptorString) {
2054
+ function parseActionDescriptorString(descriptorString) {
2046
2055
  var source = descriptorString.trim();
2047
2056
  var matches = source.match(descriptorPattern) || [];
2048
2057
  return {
2049
2058
  eventTarget: parseEventTarget(matches[4]),
2050
2059
  eventName: matches[2],
2060
+ eventOptions: matches[9] ? parseEventOptions(matches[9]) : {},
2051
2061
  identifier: matches[5],
2052
2062
  methodName: matches[7]
2053
2063
  };
@@ -2061,6 +2071,14 @@ function parseEventTarget(eventTargetName) {
2061
2071
  }
2062
2072
  }
2063
2073
 
2074
+ function parseEventOptions(eventOptions) {
2075
+ return eventOptions.split(":").reduce(function(options, token) {
2076
+ var _a;
2077
+ return Object.assign(options, (_a = {}, _a[token.replace(/^!/, "")] = !/^!/.test(token),
2078
+ _a));
2079
+ }, {});
2080
+ }
2081
+
2064
2082
  function stringifyEventTarget(eventTarget) {
2065
2083
  if (eventTarget == window) {
2066
2084
  return "window";
@@ -2075,11 +2093,12 @@ var Action = function() {
2075
2093
  this.index = index;
2076
2094
  this.eventTarget = descriptor.eventTarget || element;
2077
2095
  this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name");
2096
+ this.eventOptions = descriptor.eventOptions || {};
2078
2097
  this.identifier = descriptor.identifier || error("missing identifier");
2079
2098
  this.methodName = descriptor.methodName || error("missing method name");
2080
2099
  }
2081
2100
  Action.forToken = function(token) {
2082
- return new this(token.element, token.index, parseDescriptorString(token.content));
2101
+ return new this(token.element, token.index, parseActionDescriptorString(token.content));
2083
2102
  };
2084
2103
  Action.prototype.toString = function() {
2085
2104
  var eventNameSuffix = this.eventTargetName ? "@" + this.eventTargetName : "";
@@ -2089,7 +2108,7 @@ var Action = function() {
2089
2108
  get: function() {
2090
2109
  return stringifyEventTarget(this.eventTarget);
2091
2110
  },
2092
- enumerable: true,
2111
+ enumerable: false,
2093
2112
  configurable: true
2094
2113
  });
2095
2114
  return Action;
@@ -2106,13 +2125,13 @@ var defaultEventNames = {
2106
2125
  return "submit";
2107
2126
  },
2108
2127
  input: function(e) {
2109
- return e.getAttribute("type") == "submit" ? "click" : "change";
2128
+ return e.getAttribute("type") == "submit" ? "click" : "input";
2110
2129
  },
2111
2130
  select: function(e) {
2112
2131
  return "change";
2113
2132
  },
2114
2133
  textarea: function(e) {
2115
- return "change";
2134
+ return "input";
2116
2135
  }
2117
2136
  };
2118
2137
 
@@ -2136,21 +2155,28 @@ var Binding = function() {
2136
2155
  get: function() {
2137
2156
  return this.action.index;
2138
2157
  },
2139
- enumerable: true,
2158
+ enumerable: false,
2140
2159
  configurable: true
2141
2160
  });
2142
2161
  Object.defineProperty(Binding.prototype, "eventTarget", {
2143
2162
  get: function() {
2144
2163
  return this.action.eventTarget;
2145
2164
  },
2146
- enumerable: true,
2165
+ enumerable: false,
2166
+ configurable: true
2167
+ });
2168
+ Object.defineProperty(Binding.prototype, "eventOptions", {
2169
+ get: function() {
2170
+ return this.action.eventOptions;
2171
+ },
2172
+ enumerable: false,
2147
2173
  configurable: true
2148
2174
  });
2149
2175
  Object.defineProperty(Binding.prototype, "identifier", {
2150
2176
  get: function() {
2151
2177
  return this.context.identifier;
2152
2178
  },
2153
- enumerable: true,
2179
+ enumerable: false,
2154
2180
  configurable: true
2155
2181
  });
2156
2182
  Binding.prototype.handleEvent = function(event) {
@@ -2162,7 +2188,7 @@ var Binding = function() {
2162
2188
  get: function() {
2163
2189
  return this.action.eventName;
2164
2190
  },
2165
- enumerable: true,
2191
+ enumerable: false,
2166
2192
  configurable: true
2167
2193
  });
2168
2194
  Object.defineProperty(Binding.prototype, "method", {
@@ -2173,7 +2199,7 @@ var Binding = function() {
2173
2199
  }
2174
2200
  throw new Error('Action "' + this.action + '" references undefined method "' + this.methodName + '"');
2175
2201
  },
2176
- enumerable: true,
2202
+ enumerable: false,
2177
2203
  configurable: true
2178
2204
  });
2179
2205
  Binding.prototype.invokeWithEvent = function(event) {
@@ -2198,35 +2224,35 @@ var Binding = function() {
2198
2224
  } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {
2199
2225
  return this.scope.containsElement(eventTarget);
2200
2226
  } else {
2201
- return true;
2227
+ return this.scope.containsElement(this.action.element);
2202
2228
  }
2203
2229
  };
2204
2230
  Object.defineProperty(Binding.prototype, "controller", {
2205
2231
  get: function() {
2206
2232
  return this.context.controller;
2207
2233
  },
2208
- enumerable: true,
2234
+ enumerable: false,
2209
2235
  configurable: true
2210
2236
  });
2211
2237
  Object.defineProperty(Binding.prototype, "methodName", {
2212
2238
  get: function() {
2213
2239
  return this.action.methodName;
2214
2240
  },
2215
- enumerable: true,
2241
+ enumerable: false,
2216
2242
  configurable: true
2217
2243
  });
2218
2244
  Object.defineProperty(Binding.prototype, "element", {
2219
2245
  get: function() {
2220
2246
  return this.scope.element;
2221
2247
  },
2222
- enumerable: true,
2248
+ enumerable: false,
2223
2249
  configurable: true
2224
2250
  });
2225
2251
  Object.defineProperty(Binding.prototype, "scope", {
2226
2252
  get: function() {
2227
2253
  return this.context.scope;
2228
2254
  },
2229
- enumerable: true,
2255
+ enumerable: false,
2230
2256
  configurable: true
2231
2257
  });
2232
2258
  return Binding;
@@ -2380,14 +2406,14 @@ var AttributeObserver = function() {
2380
2406
  get: function() {
2381
2407
  return this.elementObserver.element;
2382
2408
  },
2383
- enumerable: true,
2409
+ enumerable: false,
2384
2410
  configurable: true
2385
2411
  });
2386
2412
  Object.defineProperty(AttributeObserver.prototype, "selector", {
2387
2413
  get: function() {
2388
2414
  return "[" + this.attributeName + "]";
2389
2415
  },
2390
- enumerable: true,
2416
+ enumerable: false,
2391
2417
  configurable: true
2392
2418
  });
2393
2419
  AttributeObserver.prototype.start = function() {
@@ -2403,7 +2429,7 @@ var AttributeObserver = function() {
2403
2429
  get: function() {
2404
2430
  return this.elementObserver.started;
2405
2431
  },
2406
- enumerable: true,
2432
+ enumerable: false,
2407
2433
  configurable: true
2408
2434
  });
2409
2435
  AttributeObserver.prototype.matchElement = function(element) {
@@ -2432,6 +2458,114 @@ var AttributeObserver = function() {
2432
2458
  return AttributeObserver;
2433
2459
  }();
2434
2460
 
2461
+ var StringMapObserver = function() {
2462
+ function StringMapObserver(element, delegate) {
2463
+ var _this = this;
2464
+ this.element = element;
2465
+ this.delegate = delegate;
2466
+ this.started = false;
2467
+ this.stringMap = new Map();
2468
+ this.mutationObserver = new MutationObserver(function(mutations) {
2469
+ return _this.processMutations(mutations);
2470
+ });
2471
+ }
2472
+ StringMapObserver.prototype.start = function() {
2473
+ if (!this.started) {
2474
+ this.started = true;
2475
+ this.mutationObserver.observe(this.element, {
2476
+ attributes: true
2477
+ });
2478
+ this.refresh();
2479
+ }
2480
+ };
2481
+ StringMapObserver.prototype.stop = function() {
2482
+ if (this.started) {
2483
+ this.mutationObserver.takeRecords();
2484
+ this.mutationObserver.disconnect();
2485
+ this.started = false;
2486
+ }
2487
+ };
2488
+ StringMapObserver.prototype.refresh = function() {
2489
+ if (this.started) {
2490
+ for (var _i = 0, _a = this.knownAttributeNames; _i < _a.length; _i++) {
2491
+ var attributeName = _a[_i];
2492
+ this.refreshAttribute(attributeName);
2493
+ }
2494
+ }
2495
+ };
2496
+ StringMapObserver.prototype.processMutations = function(mutations) {
2497
+ if (this.started) {
2498
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
2499
+ var mutation = mutations_1[_i];
2500
+ this.processMutation(mutation);
2501
+ }
2502
+ }
2503
+ };
2504
+ StringMapObserver.prototype.processMutation = function(mutation) {
2505
+ var attributeName = mutation.attributeName;
2506
+ if (attributeName) {
2507
+ this.refreshAttribute(attributeName);
2508
+ }
2509
+ };
2510
+ StringMapObserver.prototype.refreshAttribute = function(attributeName) {
2511
+ var key = this.delegate.getStringMapKeyForAttribute(attributeName);
2512
+ if (key != null) {
2513
+ if (!this.stringMap.has(attributeName)) {
2514
+ this.stringMapKeyAdded(key, attributeName);
2515
+ }
2516
+ var value = this.element.getAttribute(attributeName);
2517
+ if (this.stringMap.get(attributeName) != value) {
2518
+ this.stringMapValueChanged(value, key);
2519
+ }
2520
+ if (value == null) {
2521
+ this.stringMap.delete(attributeName);
2522
+ this.stringMapKeyRemoved(key, attributeName);
2523
+ } else {
2524
+ this.stringMap.set(attributeName, value);
2525
+ }
2526
+ }
2527
+ };
2528
+ StringMapObserver.prototype.stringMapKeyAdded = function(key, attributeName) {
2529
+ if (this.delegate.stringMapKeyAdded) {
2530
+ this.delegate.stringMapKeyAdded(key, attributeName);
2531
+ }
2532
+ };
2533
+ StringMapObserver.prototype.stringMapValueChanged = function(value, key) {
2534
+ if (this.delegate.stringMapValueChanged) {
2535
+ this.delegate.stringMapValueChanged(value, key);
2536
+ }
2537
+ };
2538
+ StringMapObserver.prototype.stringMapKeyRemoved = function(key, attributeName) {
2539
+ if (this.delegate.stringMapKeyRemoved) {
2540
+ this.delegate.stringMapKeyRemoved(key, attributeName);
2541
+ }
2542
+ };
2543
+ Object.defineProperty(StringMapObserver.prototype, "knownAttributeNames", {
2544
+ get: function() {
2545
+ return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)));
2546
+ },
2547
+ enumerable: false,
2548
+ configurable: true
2549
+ });
2550
+ Object.defineProperty(StringMapObserver.prototype, "currentAttributeNames", {
2551
+ get: function() {
2552
+ return Array.from(this.element.attributes).map(function(attribute) {
2553
+ return attribute.name;
2554
+ });
2555
+ },
2556
+ enumerable: false,
2557
+ configurable: true
2558
+ });
2559
+ Object.defineProperty(StringMapObserver.prototype, "recordedAttributeNames", {
2560
+ get: function() {
2561
+ return Array.from(this.stringMap.keys());
2562
+ },
2563
+ enumerable: false,
2564
+ configurable: true
2565
+ });
2566
+ return StringMapObserver;
2567
+ }();
2568
+
2435
2569
  function add(map, key, value) {
2436
2570
  fetch(map, key).add(value);
2437
2571
  }
@@ -2468,7 +2602,7 @@ var Multimap = function() {
2468
2602
  return values.concat(Array.from(set));
2469
2603
  }, []);
2470
2604
  },
2471
- enumerable: true,
2605
+ enumerable: false,
2472
2606
  configurable: true
2473
2607
  });
2474
2608
  Object.defineProperty(Multimap.prototype, "size", {
@@ -2478,7 +2612,7 @@ var Multimap = function() {
2478
2612
  return size + set.size;
2479
2613
  }, 0);
2480
2614
  },
2481
- enumerable: true,
2615
+ enumerable: false,
2482
2616
  configurable: true
2483
2617
  });
2484
2618
  Multimap.prototype.add = function(key, value) {
@@ -2517,12 +2651,15 @@ var Multimap = function() {
2517
2651
  }();
2518
2652
 
2519
2653
  var __extends = window && window.__extends || function() {
2520
- var extendStatics = Object.setPrototypeOf || {
2521
- __proto__: []
2522
- } instanceof Array && function(d, b) {
2523
- d.__proto__ = b;
2524
- } || function(d, b) {
2525
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
2654
+ var extendStatics = function(d, b) {
2655
+ extendStatics = Object.setPrototypeOf || {
2656
+ __proto__: []
2657
+ } instanceof Array && function(d, b) {
2658
+ d.__proto__ = b;
2659
+ } || function(d, b) {
2660
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
2661
+ };
2662
+ return extendStatics(d, b);
2526
2663
  };
2527
2664
  return function(d, b) {
2528
2665
  extendStatics(d, b);
@@ -2544,7 +2681,7 @@ var IndexedMultimap = function(_super) {
2544
2681
  get: function() {
2545
2682
  return Array.from(this.keysByValue.keys());
2546
2683
  },
2547
- enumerable: true,
2684
+ enumerable: false,
2548
2685
  configurable: true
2549
2686
  });
2550
2687
  IndexedMultimap.prototype.add = function(key, value) {
@@ -2575,7 +2712,7 @@ var TokenListObserver = function() {
2575
2712
  get: function() {
2576
2713
  return this.attributeObserver.started;
2577
2714
  },
2578
- enumerable: true,
2715
+ enumerable: false,
2579
2716
  configurable: true
2580
2717
  });
2581
2718
  TokenListObserver.prototype.start = function() {
@@ -2591,14 +2728,14 @@ var TokenListObserver = function() {
2591
2728
  get: function() {
2592
2729
  return this.attributeObserver.element;
2593
2730
  },
2594
- enumerable: true,
2731
+ enumerable: false,
2595
2732
  configurable: true
2596
2733
  });
2597
2734
  Object.defineProperty(TokenListObserver.prototype, "attributeName", {
2598
2735
  get: function() {
2599
2736
  return this.attributeObserver.attributeName;
2600
2737
  },
2601
- enumerable: true,
2738
+ enumerable: false,
2602
2739
  configurable: true
2603
2740
  });
2604
2741
  TokenListObserver.prototype.elementMatchedAttribute = function(element) {
@@ -2690,7 +2827,7 @@ var ValueListObserver = function() {
2690
2827
  get: function() {
2691
2828
  return this.tokenListObserver.started;
2692
2829
  },
2693
- enumerable: true,
2830
+ enumerable: false,
2694
2831
  configurable: true
2695
2832
  });
2696
2833
  ValueListObserver.prototype.start = function() {
@@ -2706,14 +2843,14 @@ var ValueListObserver = function() {
2706
2843
  get: function() {
2707
2844
  return this.tokenListObserver.element;
2708
2845
  },
2709
- enumerable: true,
2846
+ enumerable: false,
2710
2847
  configurable: true
2711
2848
  });
2712
2849
  Object.defineProperty(ValueListObserver.prototype, "attributeName", {
2713
2850
  get: function() {
2714
2851
  return this.tokenListObserver.attributeName;
2715
2852
  },
2716
- enumerable: true,
2853
+ enumerable: false,
2717
2854
  configurable: true
2718
2855
  });
2719
2856
  ValueListObserver.prototype.tokenMatched = function(token) {
@@ -2786,35 +2923,35 @@ var BindingObserver = function() {
2786
2923
  get: function() {
2787
2924
  return this.context.element;
2788
2925
  },
2789
- enumerable: true,
2926
+ enumerable: false,
2790
2927
  configurable: true
2791
2928
  });
2792
2929
  Object.defineProperty(BindingObserver.prototype, "identifier", {
2793
2930
  get: function() {
2794
2931
  return this.context.identifier;
2795
2932
  },
2796
- enumerable: true,
2933
+ enumerable: false,
2797
2934
  configurable: true
2798
2935
  });
2799
2936
  Object.defineProperty(BindingObserver.prototype, "actionAttribute", {
2800
2937
  get: function() {
2801
2938
  return this.schema.actionAttribute;
2802
2939
  },
2803
- enumerable: true,
2940
+ enumerable: false,
2804
2941
  configurable: true
2805
2942
  });
2806
2943
  Object.defineProperty(BindingObserver.prototype, "schema", {
2807
2944
  get: function() {
2808
2945
  return this.context.schema;
2809
2946
  },
2810
- enumerable: true,
2947
+ enumerable: false,
2811
2948
  configurable: true
2812
2949
  });
2813
2950
  Object.defineProperty(BindingObserver.prototype, "bindings", {
2814
2951
  get: function() {
2815
2952
  return Array.from(this.bindingsByAction.values());
2816
2953
  },
2817
- enumerable: true,
2954
+ enumerable: false,
2818
2955
  configurable: true
2819
2956
  });
2820
2957
  BindingObserver.prototype.connectAction = function(action) {
@@ -2851,12 +2988,78 @@ var BindingObserver = function() {
2851
2988
  return BindingObserver;
2852
2989
  }();
2853
2990
 
2991
+ var ValueObserver = function() {
2992
+ function ValueObserver(context, receiver) {
2993
+ this.context = context;
2994
+ this.receiver = receiver;
2995
+ this.stringMapObserver = new StringMapObserver(this.element, this);
2996
+ this.valueDescriptorMap = this.controller.valueDescriptorMap;
2997
+ this.invokeChangedCallbacksForDefaultValues();
2998
+ }
2999
+ ValueObserver.prototype.start = function() {
3000
+ this.stringMapObserver.start();
3001
+ };
3002
+ ValueObserver.prototype.stop = function() {
3003
+ this.stringMapObserver.stop();
3004
+ };
3005
+ Object.defineProperty(ValueObserver.prototype, "element", {
3006
+ get: function() {
3007
+ return this.context.element;
3008
+ },
3009
+ enumerable: false,
3010
+ configurable: true
3011
+ });
3012
+ Object.defineProperty(ValueObserver.prototype, "controller", {
3013
+ get: function() {
3014
+ return this.context.controller;
3015
+ },
3016
+ enumerable: false,
3017
+ configurable: true
3018
+ });
3019
+ ValueObserver.prototype.getStringMapKeyForAttribute = function(attributeName) {
3020
+ if (attributeName in this.valueDescriptorMap) {
3021
+ return this.valueDescriptorMap[attributeName].name;
3022
+ }
3023
+ };
3024
+ ValueObserver.prototype.stringMapValueChanged = function(attributeValue, name) {
3025
+ this.invokeChangedCallbackForValue(name);
3026
+ };
3027
+ ValueObserver.prototype.invokeChangedCallbacksForDefaultValues = function() {
3028
+ for (var _i = 0, _a = this.valueDescriptors; _i < _a.length; _i++) {
3029
+ var _b = _a[_i], key = _b.key, name_1 = _b.name, defaultValue = _b.defaultValue;
3030
+ if (defaultValue != undefined && !this.controller.data.has(key)) {
3031
+ this.invokeChangedCallbackForValue(name_1);
3032
+ }
3033
+ }
3034
+ };
3035
+ ValueObserver.prototype.invokeChangedCallbackForValue = function(name) {
3036
+ var methodName = name + "Changed";
3037
+ var method = this.receiver[methodName];
3038
+ if (typeof method == "function") {
3039
+ var value = this.receiver[name];
3040
+ method.call(this.receiver, value);
3041
+ }
3042
+ };
3043
+ Object.defineProperty(ValueObserver.prototype, "valueDescriptors", {
3044
+ get: function() {
3045
+ var valueDescriptorMap = this.valueDescriptorMap;
3046
+ return Object.keys(valueDescriptorMap).map(function(key) {
3047
+ return valueDescriptorMap[key];
3048
+ });
3049
+ },
3050
+ enumerable: false,
3051
+ configurable: true
3052
+ });
3053
+ return ValueObserver;
3054
+ }();
3055
+
2854
3056
  var Context = function() {
2855
3057
  function Context(module, scope) {
2856
3058
  this.module = module;
2857
3059
  this.scope = scope;
2858
3060
  this.controller = new module.controllerConstructor(this);
2859
3061
  this.bindingObserver = new BindingObserver(this, this.dispatcher);
3062
+ this.valueObserver = new ValueObserver(this, this.controller);
2860
3063
  try {
2861
3064
  this.controller.initialize();
2862
3065
  } catch (error) {
@@ -2865,6 +3068,7 @@ var Context = function() {
2865
3068
  }
2866
3069
  Context.prototype.connect = function() {
2867
3070
  this.bindingObserver.start();
3071
+ this.valueObserver.start();
2868
3072
  try {
2869
3073
  this.controller.connect();
2870
3074
  } catch (error) {
@@ -2877,48 +3081,49 @@ var Context = function() {
2877
3081
  } catch (error) {
2878
3082
  this.handleError(error, "disconnecting controller");
2879
3083
  }
3084
+ this.valueObserver.stop();
2880
3085
  this.bindingObserver.stop();
2881
3086
  };
2882
3087
  Object.defineProperty(Context.prototype, "application", {
2883
3088
  get: function() {
2884
3089
  return this.module.application;
2885
3090
  },
2886
- enumerable: true,
3091
+ enumerable: false,
2887
3092
  configurable: true
2888
3093
  });
2889
3094
  Object.defineProperty(Context.prototype, "identifier", {
2890
3095
  get: function() {
2891
3096
  return this.module.identifier;
2892
3097
  },
2893
- enumerable: true,
3098
+ enumerable: false,
2894
3099
  configurable: true
2895
3100
  });
2896
3101
  Object.defineProperty(Context.prototype, "schema", {
2897
3102
  get: function() {
2898
3103
  return this.application.schema;
2899
3104
  },
2900
- enumerable: true,
3105
+ enumerable: false,
2901
3106
  configurable: true
2902
3107
  });
2903
3108
  Object.defineProperty(Context.prototype, "dispatcher", {
2904
3109
  get: function() {
2905
3110
  return this.application.dispatcher;
2906
3111
  },
2907
- enumerable: true,
3112
+ enumerable: false,
2908
3113
  configurable: true
2909
3114
  });
2910
3115
  Object.defineProperty(Context.prototype, "element", {
2911
3116
  get: function() {
2912
3117
  return this.scope.element;
2913
3118
  },
2914
- enumerable: true,
3119
+ enumerable: false,
2915
3120
  configurable: true
2916
3121
  });
2917
3122
  Object.defineProperty(Context.prototype, "parentElement", {
2918
3123
  get: function() {
2919
3124
  return this.element.parentElement;
2920
3125
  },
2921
- enumerable: true,
3126
+ enumerable: false,
2922
3127
  configurable: true
2923
3128
  });
2924
3129
  Context.prototype.handleError = function(error, message, detail) {
@@ -2936,13 +3141,55 @@ var Context = function() {
2936
3141
  return Context;
2937
3142
  }();
2938
3143
 
3144
+ function readInheritableStaticArrayValues(constructor, propertyName) {
3145
+ var ancestors = getAncestorsForConstructor(constructor);
3146
+ return Array.from(ancestors.reduce(function(values, constructor) {
3147
+ getOwnStaticArrayValues(constructor, propertyName).forEach(function(name) {
3148
+ return values.add(name);
3149
+ });
3150
+ return values;
3151
+ }, new Set()));
3152
+ }
3153
+
3154
+ function readInheritableStaticObjectPairs(constructor, propertyName) {
3155
+ var ancestors = getAncestorsForConstructor(constructor);
3156
+ return ancestors.reduce(function(pairs, constructor) {
3157
+ pairs.push.apply(pairs, getOwnStaticObjectPairs(constructor, propertyName));
3158
+ return pairs;
3159
+ }, []);
3160
+ }
3161
+
3162
+ function getAncestorsForConstructor(constructor) {
3163
+ var ancestors = [];
3164
+ while (constructor) {
3165
+ ancestors.push(constructor);
3166
+ constructor = Object.getPrototypeOf(constructor);
3167
+ }
3168
+ return ancestors.reverse();
3169
+ }
3170
+
3171
+ function getOwnStaticArrayValues(constructor, propertyName) {
3172
+ var definition = constructor[propertyName];
3173
+ return Array.isArray(definition) ? definition : [];
3174
+ }
3175
+
3176
+ function getOwnStaticObjectPairs(constructor, propertyName) {
3177
+ var definition = constructor[propertyName];
3178
+ return definition ? Object.keys(definition).map(function(key) {
3179
+ return [ key, definition[key] ];
3180
+ }) : [];
3181
+ }
3182
+
2939
3183
  var __extends$1 = window && window.__extends || function() {
2940
- var extendStatics = Object.setPrototypeOf || {
2941
- __proto__: []
2942
- } instanceof Array && function(d, b) {
2943
- d.__proto__ = b;
2944
- } || function(d, b) {
2945
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3184
+ var extendStatics = function(d, b) {
3185
+ extendStatics = Object.setPrototypeOf || {
3186
+ __proto__: []
3187
+ } instanceof Array && function(d, b) {
3188
+ d.__proto__ = b;
3189
+ } || function(d, b) {
3190
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3191
+ };
3192
+ return extendStatics(d, b);
2946
3193
  };
2947
3194
  return function(d, b) {
2948
3195
  extendStatics(d, b);
@@ -2953,32 +3200,83 @@ var __extends$1 = window && window.__extends || function() {
2953
3200
  };
2954
3201
  }();
2955
3202
 
2956
- function blessDefinition(definition) {
2957
- return {
2958
- identifier: definition.identifier,
2959
- controllerConstructor: blessControllerConstructor(definition.controllerConstructor)
2960
- };
3203
+ var __spreadArrays = window && window.__spreadArrays || function() {
3204
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3205
+ for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++,
3206
+ k++) r[k] = a[j];
3207
+ return r;
3208
+ };
3209
+
3210
+ function bless(constructor) {
3211
+ return shadow(constructor, getBlessedProperties(constructor));
3212
+ }
3213
+
3214
+ function shadow(constructor, properties) {
3215
+ var shadowConstructor = extend(constructor);
3216
+ var shadowProperties = getShadowProperties(constructor.prototype, properties);
3217
+ Object.defineProperties(shadowConstructor.prototype, shadowProperties);
3218
+ return shadowConstructor;
3219
+ }
3220
+
3221
+ function getBlessedProperties(constructor) {
3222
+ var blessings = readInheritableStaticArrayValues(constructor, "blessings");
3223
+ return blessings.reduce(function(blessedProperties, blessing) {
3224
+ var properties = blessing(constructor);
3225
+ for (var key in properties) {
3226
+ var descriptor = blessedProperties[key] || {};
3227
+ blessedProperties[key] = Object.assign(descriptor, properties[key]);
3228
+ }
3229
+ return blessedProperties;
3230
+ }, {});
3231
+ }
3232
+
3233
+ function getShadowProperties(prototype, properties) {
3234
+ return getOwnKeys(properties).reduce(function(shadowProperties, key) {
3235
+ var _a;
3236
+ var descriptor = getShadowedDescriptor(prototype, properties, key);
3237
+ if (descriptor) {
3238
+ Object.assign(shadowProperties, (_a = {}, _a[key] = descriptor, _a));
3239
+ }
3240
+ return shadowProperties;
3241
+ }, {});
2961
3242
  }
2962
3243
 
2963
- function blessControllerConstructor(controllerConstructor) {
2964
- var constructor = extend(controllerConstructor);
2965
- constructor.bless();
2966
- return constructor;
3244
+ function getShadowedDescriptor(prototype, properties, key) {
3245
+ var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
3246
+ var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor;
3247
+ if (!shadowedByValue) {
3248
+ var descriptor = Object.getOwnPropertyDescriptor(properties, key).value;
3249
+ if (shadowingDescriptor) {
3250
+ descriptor.get = shadowingDescriptor.get || descriptor.get;
3251
+ descriptor.set = shadowingDescriptor.set || descriptor.set;
3252
+ }
3253
+ return descriptor;
3254
+ }
2967
3255
  }
2968
3256
 
3257
+ var getOwnKeys = function() {
3258
+ if (typeof Object.getOwnPropertySymbols == "function") {
3259
+ return function(object) {
3260
+ return __spreadArrays(Object.getOwnPropertyNames(object), Object.getOwnPropertySymbols(object));
3261
+ };
3262
+ } else {
3263
+ return Object.getOwnPropertyNames;
3264
+ }
3265
+ }();
3266
+
2969
3267
  var extend = function() {
2970
3268
  function extendWithReflect(constructor) {
2971
- function Controller() {
2972
- var _newTarget = this && this instanceof Controller ? this.constructor : void 0;
3269
+ function extended() {
3270
+ var _newTarget = this && this instanceof extended ? this.constructor : void 0;
2973
3271
  return Reflect.construct(constructor, arguments, _newTarget);
2974
3272
  }
2975
- Controller.prototype = Object.create(constructor.prototype, {
3273
+ extended.prototype = Object.create(constructor.prototype, {
2976
3274
  constructor: {
2977
- value: Controller
3275
+ value: extended
2978
3276
  }
2979
3277
  });
2980
- Reflect.setPrototypeOf(Controller, constructor);
2981
- return Controller;
3278
+ Reflect.setPrototypeOf(extended, constructor);
3279
+ return extended;
2982
3280
  }
2983
3281
  function testReflectExtension() {
2984
3282
  var a = function() {
@@ -2994,16 +3292,23 @@ var extend = function() {
2994
3292
  } catch (error) {
2995
3293
  return function(constructor) {
2996
3294
  return function(_super) {
2997
- __extends$1(Controller, _super);
2998
- function Controller() {
3295
+ __extends$1(extended, _super);
3296
+ function extended() {
2999
3297
  return _super !== null && _super.apply(this, arguments) || this;
3000
3298
  }
3001
- return Controller;
3299
+ return extended;
3002
3300
  }(constructor);
3003
3301
  };
3004
3302
  }
3005
3303
  }();
3006
3304
 
3305
+ function blessDefinition(definition) {
3306
+ return {
3307
+ identifier: definition.identifier,
3308
+ controllerConstructor: bless(definition.controllerConstructor)
3309
+ };
3310
+ }
3311
+
3007
3312
  var Module = function() {
3008
3313
  function Module(application, definition) {
3009
3314
  this.application = application;
@@ -3015,21 +3320,21 @@ var Module = function() {
3015
3320
  get: function() {
3016
3321
  return this.definition.identifier;
3017
3322
  },
3018
- enumerable: true,
3323
+ enumerable: false,
3019
3324
  configurable: true
3020
3325
  });
3021
3326
  Object.defineProperty(Module.prototype, "controllerConstructor", {
3022
3327
  get: function() {
3023
3328
  return this.definition.controllerConstructor;
3024
3329
  },
3025
- enumerable: true,
3330
+ enumerable: false,
3026
3331
  configurable: true
3027
3332
  });
3028
3333
  Object.defineProperty(Module.prototype, "contexts", {
3029
3334
  get: function() {
3030
3335
  return Array.from(this.connectedContexts);
3031
3336
  },
3032
- enumerable: true,
3337
+ enumerable: false,
3033
3338
  configurable: true
3034
3339
  });
3035
3340
  Module.prototype.connectContextForScope = function(scope) {
@@ -3055,6 +3360,48 @@ var Module = function() {
3055
3360
  return Module;
3056
3361
  }();
3057
3362
 
3363
+ var ClassMap = function() {
3364
+ function ClassMap(scope) {
3365
+ this.scope = scope;
3366
+ }
3367
+ ClassMap.prototype.has = function(name) {
3368
+ return this.data.has(this.getDataKey(name));
3369
+ };
3370
+ ClassMap.prototype.get = function(name) {
3371
+ return this.data.get(this.getDataKey(name));
3372
+ };
3373
+ ClassMap.prototype.getAttributeName = function(name) {
3374
+ return this.data.getAttributeNameForKey(this.getDataKey(name));
3375
+ };
3376
+ ClassMap.prototype.getDataKey = function(name) {
3377
+ return name + "-class";
3378
+ };
3379
+ Object.defineProperty(ClassMap.prototype, "data", {
3380
+ get: function() {
3381
+ return this.scope.data;
3382
+ },
3383
+ enumerable: false,
3384
+ configurable: true
3385
+ });
3386
+ return ClassMap;
3387
+ }();
3388
+
3389
+ function camelize(value) {
3390
+ return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) {
3391
+ return char.toUpperCase();
3392
+ });
3393
+ }
3394
+
3395
+ function capitalize(value) {
3396
+ return value.charAt(0).toUpperCase() + value.slice(1);
3397
+ }
3398
+
3399
+ function dasherize(value) {
3400
+ return value.replace(/([A-Z])/g, function(_, char) {
3401
+ return "-" + char.toLowerCase();
3402
+ });
3403
+ }
3404
+
3058
3405
  var DataMap = function() {
3059
3406
  function DataMap(scope) {
3060
3407
  this.scope = scope;
@@ -3063,54 +3410,74 @@ var DataMap = function() {
3063
3410
  get: function() {
3064
3411
  return this.scope.element;
3065
3412
  },
3066
- enumerable: true,
3413
+ enumerable: false,
3067
3414
  configurable: true
3068
3415
  });
3069
3416
  Object.defineProperty(DataMap.prototype, "identifier", {
3070
3417
  get: function() {
3071
3418
  return this.scope.identifier;
3072
3419
  },
3073
- enumerable: true,
3420
+ enumerable: false,
3074
3421
  configurable: true
3075
3422
  });
3076
3423
  DataMap.prototype.get = function(key) {
3077
- key = this.getFormattedKey(key);
3078
- return this.element.getAttribute(key);
3424
+ var name = this.getAttributeNameForKey(key);
3425
+ return this.element.getAttribute(name);
3079
3426
  };
3080
3427
  DataMap.prototype.set = function(key, value) {
3081
- key = this.getFormattedKey(key);
3082
- this.element.setAttribute(key, value);
3428
+ var name = this.getAttributeNameForKey(key);
3429
+ this.element.setAttribute(name, value);
3083
3430
  return this.get(key);
3084
3431
  };
3085
3432
  DataMap.prototype.has = function(key) {
3086
- key = this.getFormattedKey(key);
3087
- return this.element.hasAttribute(key);
3433
+ var name = this.getAttributeNameForKey(key);
3434
+ return this.element.hasAttribute(name);
3088
3435
  };
3089
3436
  DataMap.prototype.delete = function(key) {
3090
3437
  if (this.has(key)) {
3091
- key = this.getFormattedKey(key);
3092
- this.element.removeAttribute(key);
3438
+ var name_1 = this.getAttributeNameForKey(key);
3439
+ this.element.removeAttribute(name_1);
3093
3440
  return true;
3094
3441
  } else {
3095
3442
  return false;
3096
3443
  }
3097
3444
  };
3098
- DataMap.prototype.getFormattedKey = function(key) {
3445
+ DataMap.prototype.getAttributeNameForKey = function(key) {
3099
3446
  return "data-" + this.identifier + "-" + dasherize(key);
3100
3447
  };
3101
3448
  return DataMap;
3102
3449
  }();
3103
3450
 
3104
- function dasherize(value) {
3105
- return value.replace(/([A-Z])/g, function(_, char) {
3106
- return "-" + char.toLowerCase();
3107
- });
3108
- }
3451
+ var Guide = function() {
3452
+ function Guide(logger) {
3453
+ this.warnedKeysByObject = new WeakMap();
3454
+ this.logger = logger;
3455
+ }
3456
+ Guide.prototype.warn = function(object, key, message) {
3457
+ var warnedKeys = this.warnedKeysByObject.get(object);
3458
+ if (!warnedKeys) {
3459
+ warnedKeys = new Set();
3460
+ this.warnedKeysByObject.set(object, warnedKeys);
3461
+ }
3462
+ if (!warnedKeys.has(key)) {
3463
+ warnedKeys.add(key);
3464
+ this.logger.warn(message, object);
3465
+ }
3466
+ };
3467
+ return Guide;
3468
+ }();
3109
3469
 
3110
3470
  function attributeValueContainsToken(attributeName, token) {
3111
3471
  return "[" + attributeName + '~="' + token + '"]';
3112
3472
  }
3113
3473
 
3474
+ var __spreadArrays$1 = window && window.__spreadArrays || function() {
3475
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3476
+ for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++,
3477
+ k++) r[k] = a[j];
3478
+ return r;
3479
+ };
3480
+
3114
3481
  var TargetSet = function() {
3115
3482
  function TargetSet(scope) {
3116
3483
  this.scope = scope;
@@ -3119,85 +3486,126 @@ var TargetSet = function() {
3119
3486
  get: function() {
3120
3487
  return this.scope.element;
3121
3488
  },
3122
- enumerable: true,
3489
+ enumerable: false,
3123
3490
  configurable: true
3124
3491
  });
3125
3492
  Object.defineProperty(TargetSet.prototype, "identifier", {
3126
3493
  get: function() {
3127
3494
  return this.scope.identifier;
3128
3495
  },
3129
- enumerable: true,
3496
+ enumerable: false,
3130
3497
  configurable: true
3131
3498
  });
3132
3499
  Object.defineProperty(TargetSet.prototype, "schema", {
3133
3500
  get: function() {
3134
3501
  return this.scope.schema;
3135
3502
  },
3136
- enumerable: true,
3503
+ enumerable: false,
3137
3504
  configurable: true
3138
3505
  });
3139
3506
  TargetSet.prototype.has = function(targetName) {
3140
3507
  return this.find(targetName) != null;
3141
3508
  };
3142
3509
  TargetSet.prototype.find = function() {
3510
+ var _this = this;
3143
3511
  var targetNames = [];
3144
3512
  for (var _i = 0; _i < arguments.length; _i++) {
3145
3513
  targetNames[_i] = arguments[_i];
3146
3514
  }
3147
- var selector = this.getSelectorForTargetNames(targetNames);
3148
- return this.scope.findElement(selector);
3515
+ return targetNames.reduce(function(target, targetName) {
3516
+ return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName);
3517
+ }, undefined);
3149
3518
  };
3150
3519
  TargetSet.prototype.findAll = function() {
3520
+ var _this = this;
3151
3521
  var targetNames = [];
3152
3522
  for (var _i = 0; _i < arguments.length; _i++) {
3153
3523
  targetNames[_i] = arguments[_i];
3154
3524
  }
3155
- var selector = this.getSelectorForTargetNames(targetNames);
3525
+ return targetNames.reduce(function(targets, targetName) {
3526
+ return __spreadArrays$1(targets, _this.findAllTargets(targetName), _this.findAllLegacyTargets(targetName));
3527
+ }, []);
3528
+ };
3529
+ TargetSet.prototype.findTarget = function(targetName) {
3530
+ var selector = this.getSelectorForTargetName(targetName);
3531
+ return this.scope.findElement(selector);
3532
+ };
3533
+ TargetSet.prototype.findAllTargets = function(targetName) {
3534
+ var selector = this.getSelectorForTargetName(targetName);
3156
3535
  return this.scope.findAllElements(selector);
3157
3536
  };
3158
- TargetSet.prototype.getSelectorForTargetNames = function(targetNames) {
3537
+ TargetSet.prototype.getSelectorForTargetName = function(targetName) {
3538
+ var attributeName = "data-" + this.identifier + "-target";
3539
+ return attributeValueContainsToken(attributeName, targetName);
3540
+ };
3541
+ TargetSet.prototype.findLegacyTarget = function(targetName) {
3542
+ var selector = this.getLegacySelectorForTargetName(targetName);
3543
+ return this.deprecate(this.scope.findElement(selector), targetName);
3544
+ };
3545
+ TargetSet.prototype.findAllLegacyTargets = function(targetName) {
3159
3546
  var _this = this;
3160
- return targetNames.map(function(targetName) {
3161
- return _this.getSelectorForTargetName(targetName);
3162
- }).join(", ");
3547
+ var selector = this.getLegacySelectorForTargetName(targetName);
3548
+ return this.scope.findAllElements(selector).map(function(element) {
3549
+ return _this.deprecate(element, targetName);
3550
+ });
3163
3551
  };
3164
- TargetSet.prototype.getSelectorForTargetName = function(targetName) {
3552
+ TargetSet.prototype.getLegacySelectorForTargetName = function(targetName) {
3165
3553
  var targetDescriptor = this.identifier + "." + targetName;
3166
3554
  return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);
3167
3555
  };
3556
+ TargetSet.prototype.deprecate = function(element, targetName) {
3557
+ if (element) {
3558
+ var identifier = this.identifier;
3559
+ var attributeName = this.schema.targetAttribute;
3560
+ this.guide.warn(element, "target:" + targetName, "Please replace " + attributeName + '="' + identifier + "." + targetName + '" with data-' + identifier + '-target="' + targetName + '". ' + ("The " + attributeName + " attribute is deprecated and will be removed in a future version of Stimulus."));
3561
+ }
3562
+ return element;
3563
+ };
3564
+ Object.defineProperty(TargetSet.prototype, "guide", {
3565
+ get: function() {
3566
+ return this.scope.guide;
3567
+ },
3568
+ enumerable: false,
3569
+ configurable: true
3570
+ });
3168
3571
  return TargetSet;
3169
3572
  }();
3170
3573
 
3574
+ var __spreadArrays$2 = window && window.__spreadArrays || function() {
3575
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3576
+ for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++,
3577
+ k++) r[k] = a[j];
3578
+ return r;
3579
+ };
3580
+
3171
3581
  var Scope = function() {
3172
- function Scope(schema, identifier, element) {
3173
- this.schema = schema;
3174
- this.identifier = identifier;
3175
- this.element = element;
3582
+ function Scope(schema, element, identifier, logger) {
3583
+ var _this = this;
3176
3584
  this.targets = new TargetSet(this);
3585
+ this.classes = new ClassMap(this);
3177
3586
  this.data = new DataMap(this);
3587
+ this.containsElement = function(element) {
3588
+ return element.closest(_this.controllerSelector) === _this.element;
3589
+ };
3590
+ this.schema = schema;
3591
+ this.element = element;
3592
+ this.identifier = identifier;
3593
+ this.guide = new Guide(logger);
3178
3594
  }
3179
3595
  Scope.prototype.findElement = function(selector) {
3180
- return this.findAllElements(selector)[0];
3596
+ return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement);
3181
3597
  };
3182
3598
  Scope.prototype.findAllElements = function(selector) {
3183
- var head = this.element.matches(selector) ? [ this.element ] : [];
3184
- var tail = this.filterElements(Array.from(this.element.querySelectorAll(selector)));
3185
- return head.concat(tail);
3186
- };
3187
- Scope.prototype.filterElements = function(elements) {
3188
- var _this = this;
3189
- return elements.filter(function(element) {
3190
- return _this.containsElement(element);
3191
- });
3599
+ return __spreadArrays$2(this.element.matches(selector) ? [ this.element ] : [], this.queryElements(selector).filter(this.containsElement));
3192
3600
  };
3193
- Scope.prototype.containsElement = function(element) {
3194
- return element.closest(this.controllerSelector) === this.element;
3601
+ Scope.prototype.queryElements = function(selector) {
3602
+ return Array.from(this.element.querySelectorAll(selector));
3195
3603
  };
3196
3604
  Object.defineProperty(Scope.prototype, "controllerSelector", {
3197
3605
  get: function() {
3198
3606
  return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);
3199
3607
  },
3200
- enumerable: true,
3608
+ enumerable: false,
3201
3609
  configurable: true
3202
3610
  });
3203
3611
  return Scope;
@@ -3222,7 +3630,7 @@ var ScopeObserver = function() {
3222
3630
  get: function() {
3223
3631
  return this.schema.controllerAttribute;
3224
3632
  },
3225
- enumerable: true,
3633
+ enumerable: false,
3226
3634
  configurable: true
3227
3635
  });
3228
3636
  ScopeObserver.prototype.parseValueForToken = function(token) {
@@ -3230,7 +3638,7 @@ var ScopeObserver = function() {
3230
3638
  var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);
3231
3639
  var scope = scopesByIdentifier.get(identifier);
3232
3640
  if (!scope) {
3233
- scope = new Scope(this.schema, identifier, element);
3641
+ scope = this.delegate.createScopeForElementAndIdentifier(element, identifier);
3234
3642
  scopesByIdentifier.set(identifier, scope);
3235
3643
  }
3236
3644
  return scope;
@@ -3273,28 +3681,35 @@ var Router = function() {
3273
3681
  get: function() {
3274
3682
  return this.application.element;
3275
3683
  },
3276
- enumerable: true,
3684
+ enumerable: false,
3277
3685
  configurable: true
3278
3686
  });
3279
3687
  Object.defineProperty(Router.prototype, "schema", {
3280
3688
  get: function() {
3281
3689
  return this.application.schema;
3282
3690
  },
3283
- enumerable: true,
3691
+ enumerable: false,
3692
+ configurable: true
3693
+ });
3694
+ Object.defineProperty(Router.prototype, "logger", {
3695
+ get: function() {
3696
+ return this.application.logger;
3697
+ },
3698
+ enumerable: false,
3284
3699
  configurable: true
3285
3700
  });
3286
3701
  Object.defineProperty(Router.prototype, "controllerAttribute", {
3287
3702
  get: function() {
3288
3703
  return this.schema.controllerAttribute;
3289
3704
  },
3290
- enumerable: true,
3705
+ enumerable: false,
3291
3706
  configurable: true
3292
3707
  });
3293
3708
  Object.defineProperty(Router.prototype, "modules", {
3294
3709
  get: function() {
3295
3710
  return Array.from(this.modulesByIdentifier.values());
3296
3711
  },
3297
- enumerable: true,
3712
+ enumerable: false,
3298
3713
  configurable: true
3299
3714
  });
3300
3715
  Object.defineProperty(Router.prototype, "contexts", {
@@ -3303,7 +3718,7 @@ var Router = function() {
3303
3718
  return contexts.concat(module.contexts);
3304
3719
  }, []);
3305
3720
  },
3306
- enumerable: true,
3721
+ enumerable: false,
3307
3722
  configurable: true
3308
3723
  });
3309
3724
  Router.prototype.start = function() {
@@ -3334,6 +3749,9 @@ var Router = function() {
3334
3749
  Router.prototype.handleError = function(error, message, detail) {
3335
3750
  this.application.handleError(error, message, detail);
3336
3751
  };
3752
+ Router.prototype.createScopeForElementAndIdentifier = function(element, identifier) {
3753
+ return new Scope(this.schema, element, identifier, this.logger);
3754
+ };
3337
3755
  Router.prototype.scopeConnected = function(scope) {
3338
3756
  this.scopesByIdentifier.add(scope.identifier, scope);
3339
3757
  var module = this.modulesByIdentifier.get(scope.identifier);
@@ -3372,6 +3790,11 @@ var defaultSchema = {
3372
3790
  };
3373
3791
 
3374
3792
  var __awaiter = window && window.__awaiter || function(thisArg, _arguments, P, generator) {
3793
+ function adopt(value) {
3794
+ return value instanceof P ? value : new P(function(resolve) {
3795
+ resolve(value);
3796
+ });
3797
+ }
3375
3798
  return new (P || (P = Promise))(function(resolve, reject) {
3376
3799
  function fulfilled(value) {
3377
3800
  try {
@@ -3388,9 +3811,7 @@ var __awaiter = window && window.__awaiter || function(thisArg, _arguments, P, g
3388
3811
  }
3389
3812
  }
3390
3813
  function step(result) {
3391
- result.done ? resolve(result.value) : new P(function(resolve) {
3392
- resolve(result.value);
3393
- }).then(fulfilled, rejected);
3814
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
3394
3815
  }
3395
3816
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3396
3817
  });
@@ -3421,8 +3842,9 @@ var __generator = window && window.__generator || function(thisArg, body) {
3421
3842
  function step(op) {
3422
3843
  if (f) throw new TypeError("Generator is already executing.");
3423
3844
  while (_) try {
3424
- if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
3425
- if (y = 0, t) op = [ 0, t.value ];
3845
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y),
3846
+ 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3847
+ if (y = 0, t) op = [ op[0] & 2, t.value ];
3426
3848
  switch (op[0]) {
3427
3849
  case 0:
3428
3850
  case 1:
@@ -3485,6 +3907,13 @@ var __generator = window && window.__generator || function(thisArg, body) {
3485
3907
  }
3486
3908
  };
3487
3909
 
3910
+ var __spreadArrays$3 = window && window.__spreadArrays || function() {
3911
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3912
+ for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++,
3913
+ k++) r[k] = a[j];
3914
+ return r;
3915
+ };
3916
+
3488
3917
  var Application = function() {
3489
3918
  function Application(element, schema) {
3490
3919
  if (element === void 0) {
@@ -3493,6 +3922,7 @@ var Application = function() {
3493
3922
  if (schema === void 0) {
3494
3923
  schema = defaultSchema;
3495
3924
  }
3925
+ this.logger = console;
3496
3926
  this.element = element;
3497
3927
  this.schema = schema;
3498
3928
  this.dispatcher = new Dispatcher(this);
@@ -3512,16 +3942,16 @@ var Application = function() {
3512
3942
 
3513
3943
  case 1:
3514
3944
  _a.sent();
3515
- this.router.start();
3516
3945
  this.dispatcher.start();
3946
+ this.router.start();
3517
3947
  return [ 2 ];
3518
3948
  }
3519
3949
  });
3520
3950
  });
3521
3951
  };
3522
3952
  Application.prototype.stop = function() {
3523
- this.router.stop();
3524
3953
  this.dispatcher.stop();
3954
+ this.router.stop();
3525
3955
  };
3526
3956
  Application.prototype.register = function(identifier, controllerConstructor) {
3527
3957
  this.load({
@@ -3535,7 +3965,7 @@ var Application = function() {
3535
3965
  for (var _i = 1; _i < arguments.length; _i++) {
3536
3966
  rest[_i - 1] = arguments[_i];
3537
3967
  }
3538
- var definitions = Array.isArray(head) ? head : [ head ].concat(rest);
3968
+ var definitions = Array.isArray(head) ? head : __spreadArrays$3([ head ], rest);
3539
3969
  definitions.forEach(function(definition) {
3540
3970
  return _this.router.loadDefinition(definition);
3541
3971
  });
@@ -3546,7 +3976,7 @@ var Application = function() {
3546
3976
  for (var _i = 1; _i < arguments.length; _i++) {
3547
3977
  rest[_i - 1] = arguments[_i];
3548
3978
  }
3549
- var identifiers = Array.isArray(head) ? head : [ head ].concat(rest);
3979
+ var identifiers = Array.isArray(head) ? head : __spreadArrays$3([ head ], rest);
3550
3980
  identifiers.forEach(function(identifier) {
3551
3981
  return _this.router.unloadIdentifier(identifier);
3552
3982
  });
@@ -3557,7 +3987,7 @@ var Application = function() {
3557
3987
  return context.controller;
3558
3988
  });
3559
3989
  },
3560
- enumerable: true,
3990
+ enumerable: false,
3561
3991
  configurable: true
3562
3992
  });
3563
3993
  Application.prototype.getControllerForElementAndIdentifier = function(element, identifier) {
@@ -3565,7 +3995,7 @@ var Application = function() {
3565
3995
  return context ? context.controller : null;
3566
3996
  };
3567
3997
  Application.prototype.handleError = function(error, message, detail) {
3568
- console.error("%s\n\n%o\n\n%o", message, error, detail);
3998
+ this.logger.error("%s\n\n%o\n\n%o", message, error, detail);
3569
3999
  };
3570
4000
  return Application;
3571
4001
  }();
@@ -3580,122 +4010,259 @@ function domReady() {
3580
4010
  });
3581
4011
  }
3582
4012
 
3583
- function defineTargetProperties(constructor) {
3584
- var prototype = constructor.prototype;
3585
- var targetNames = getTargetNamesForConstructor(constructor);
3586
- targetNames.forEach(function(name) {
3587
- var _a;
3588
- return defineLinkedProperties(prototype, (_a = {}, _a[name + "Target"] = {
3589
- get: function() {
3590
- var target = this.targets.find(name);
3591
- if (target) {
3592
- return target;
3593
- } else {
3594
- throw new Error('Missing target element "' + this.identifier + "." + name + '"');
3595
- }
4013
+ function ClassPropertiesBlessing(constructor) {
4014
+ var classes = readInheritableStaticArrayValues(constructor, "classes");
4015
+ return classes.reduce(function(properties, classDefinition) {
4016
+ return Object.assign(properties, propertiesForClassDefinition(classDefinition));
4017
+ }, {});
4018
+ }
4019
+
4020
+ function propertiesForClassDefinition(key) {
4021
+ var _a;
4022
+ var name = key + "Class";
4023
+ return _a = {}, _a[name] = {
4024
+ get: function() {
4025
+ var classes = this.classes;
4026
+ if (classes.has(key)) {
4027
+ return classes.get(key);
4028
+ } else {
4029
+ var attribute = classes.getAttributeName(key);
4030
+ throw new Error('Missing attribute "' + attribute + '"');
3596
4031
  }
3597
- }, _a[name + "Targets"] = {
3598
- get: function() {
3599
- return this.targets.findAll(name);
4032
+ }
4033
+ }, _a["has" + capitalize(name)] = {
4034
+ get: function() {
4035
+ return this.classes.has(key);
4036
+ }
4037
+ }, _a;
4038
+ }
4039
+
4040
+ function TargetPropertiesBlessing(constructor) {
4041
+ var targets = readInheritableStaticArrayValues(constructor, "targets");
4042
+ return targets.reduce(function(properties, targetDefinition) {
4043
+ return Object.assign(properties, propertiesForTargetDefinition(targetDefinition));
4044
+ }, {});
4045
+ }
4046
+
4047
+ function propertiesForTargetDefinition(name) {
4048
+ var _a;
4049
+ return _a = {}, _a[name + "Target"] = {
4050
+ get: function() {
4051
+ var target = this.targets.find(name);
4052
+ if (target) {
4053
+ return target;
4054
+ } else {
4055
+ throw new Error('Missing target element "' + this.identifier + "." + name + '"');
3600
4056
  }
3601
- }, _a["has" + capitalize(name) + "Target"] = {
4057
+ }
4058
+ }, _a[name + "Targets"] = {
4059
+ get: function() {
4060
+ return this.targets.findAll(name);
4061
+ }
4062
+ }, _a["has" + capitalize(name) + "Target"] = {
4063
+ get: function() {
4064
+ return this.targets.has(name);
4065
+ }
4066
+ }, _a;
4067
+ }
4068
+
4069
+ function ValuePropertiesBlessing(constructor) {
4070
+ var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values");
4071
+ var propertyDescriptorMap = {
4072
+ valueDescriptorMap: {
3602
4073
  get: function() {
3603
- return this.targets.has(name);
4074
+ var _this = this;
4075
+ return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) {
4076
+ var _a;
4077
+ var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair);
4078
+ var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key);
4079
+ return Object.assign(result, (_a = {}, _a[attributeName] = valueDescriptor, _a));
4080
+ }, {});
3604
4081
  }
3605
- }, _a));
3606
- });
4082
+ }
4083
+ };
4084
+ return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) {
4085
+ return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair));
4086
+ }, propertyDescriptorMap);
3607
4087
  }
3608
4088
 
3609
- function getTargetNamesForConstructor(constructor) {
3610
- var ancestors = getAncestorsForConstructor(constructor);
3611
- return Array.from(ancestors.reduce(function(targetNames, constructor) {
3612
- getOwnTargetNamesForConstructor(constructor).forEach(function(name) {
3613
- return targetNames.add(name);
3614
- });
3615
- return targetNames;
3616
- }, new Set()));
4089
+ function propertiesForValueDefinitionPair(valueDefinitionPair) {
4090
+ var _a;
4091
+ var definition = parseValueDefinitionPair(valueDefinitionPair);
4092
+ var type = definition.type, key = definition.key, name = definition.name;
4093
+ var read = readers[type], write = writers[type] || writers.default;
4094
+ return _a = {}, _a[name] = {
4095
+ get: function() {
4096
+ var value = this.data.get(key);
4097
+ if (value !== null) {
4098
+ return read(value);
4099
+ } else {
4100
+ return definition.defaultValue;
4101
+ }
4102
+ },
4103
+ set: function(value) {
4104
+ if (value === undefined) {
4105
+ this.data.delete(key);
4106
+ } else {
4107
+ this.data.set(key, write(value));
4108
+ }
4109
+ }
4110
+ }, _a["has" + capitalize(name)] = {
4111
+ get: function() {
4112
+ return this.data.has(key);
4113
+ }
4114
+ }, _a;
3617
4115
  }
3618
4116
 
3619
- function getAncestorsForConstructor(constructor) {
3620
- var ancestors = [];
3621
- while (constructor) {
3622
- ancestors.push(constructor);
3623
- constructor = Object.getPrototypeOf(constructor);
4117
+ function parseValueDefinitionPair(_a) {
4118
+ var token = _a[0], typeConstant = _a[1];
4119
+ var type = parseValueTypeConstant(typeConstant);
4120
+ return valueDescriptorForTokenAndType(token, type);
4121
+ }
4122
+
4123
+ function parseValueTypeConstant(typeConstant) {
4124
+ switch (typeConstant) {
4125
+ case Array:
4126
+ return "array";
4127
+
4128
+ case Boolean:
4129
+ return "boolean";
4130
+
4131
+ case Number:
4132
+ return "number";
4133
+
4134
+ case Object:
4135
+ return "object";
4136
+
4137
+ case String:
4138
+ return "string";
3624
4139
  }
3625
- return ancestors;
4140
+ throw new Error('Unknown value type constant "' + typeConstant + '"');
3626
4141
  }
3627
4142
 
3628
- function getOwnTargetNamesForConstructor(constructor) {
3629
- var definition = constructor["targets"];
3630
- return Array.isArray(definition) ? definition : [];
4143
+ function valueDescriptorForTokenAndType(token, type) {
4144
+ var key = dasherize(token) + "-value";
4145
+ return {
4146
+ type: type,
4147
+ key: key,
4148
+ name: camelize(key),
4149
+ get defaultValue() {
4150
+ return defaultValuesByType[type];
4151
+ }
4152
+ };
3631
4153
  }
3632
4154
 
3633
- function defineLinkedProperties(object, properties) {
3634
- Object.keys(properties).forEach(function(name) {
3635
- if (!(name in object)) {
3636
- var descriptor = properties[name];
3637
- Object.defineProperty(object, name, descriptor);
4155
+ var defaultValuesByType = {
4156
+ get array() {
4157
+ return [];
4158
+ },
4159
+ boolean: false,
4160
+ number: 0,
4161
+ get object() {
4162
+ return {};
4163
+ },
4164
+ string: ""
4165
+ };
4166
+
4167
+ var readers = {
4168
+ array: function(value) {
4169
+ var array = JSON.parse(value);
4170
+ if (!Array.isArray(array)) {
4171
+ throw new TypeError("Expected array");
3638
4172
  }
3639
- });
4173
+ return array;
4174
+ },
4175
+ boolean: function(value) {
4176
+ return !(value == "0" || value == "false");
4177
+ },
4178
+ number: function(value) {
4179
+ return parseFloat(value);
4180
+ },
4181
+ object: function(value) {
4182
+ var object = JSON.parse(value);
4183
+ if (object === null || typeof object != "object" || Array.isArray(object)) {
4184
+ throw new TypeError("Expected object");
4185
+ }
4186
+ return object;
4187
+ },
4188
+ string: function(value) {
4189
+ return value;
4190
+ }
4191
+ };
4192
+
4193
+ var writers = {
4194
+ default: writeString,
4195
+ array: writeJSON,
4196
+ object: writeJSON
4197
+ };
4198
+
4199
+ function writeJSON(value) {
4200
+ return JSON.stringify(value);
3640
4201
  }
3641
4202
 
3642
- function capitalize(name) {
3643
- return name.charAt(0).toUpperCase() + name.slice(1);
4203
+ function writeString(value) {
4204
+ return "" + value;
3644
4205
  }
3645
4206
 
3646
4207
  var Controller = function() {
3647
4208
  function Controller(context) {
3648
4209
  this.context = context;
3649
4210
  }
3650
- Controller.bless = function() {
3651
- defineTargetProperties(this);
3652
- };
3653
4211
  Object.defineProperty(Controller.prototype, "application", {
3654
4212
  get: function() {
3655
4213
  return this.context.application;
3656
4214
  },
3657
- enumerable: true,
4215
+ enumerable: false,
3658
4216
  configurable: true
3659
4217
  });
3660
4218
  Object.defineProperty(Controller.prototype, "scope", {
3661
4219
  get: function() {
3662
4220
  return this.context.scope;
3663
4221
  },
3664
- enumerable: true,
4222
+ enumerable: false,
3665
4223
  configurable: true
3666
4224
  });
3667
4225
  Object.defineProperty(Controller.prototype, "element", {
3668
4226
  get: function() {
3669
4227
  return this.scope.element;
3670
4228
  },
3671
- enumerable: true,
4229
+ enumerable: false,
3672
4230
  configurable: true
3673
4231
  });
3674
4232
  Object.defineProperty(Controller.prototype, "identifier", {
3675
4233
  get: function() {
3676
4234
  return this.scope.identifier;
3677
4235
  },
3678
- enumerable: true,
4236
+ enumerable: false,
3679
4237
  configurable: true
3680
4238
  });
3681
4239
  Object.defineProperty(Controller.prototype, "targets", {
3682
4240
  get: function() {
3683
4241
  return this.scope.targets;
3684
4242
  },
3685
- enumerable: true,
4243
+ enumerable: false,
4244
+ configurable: true
4245
+ });
4246
+ Object.defineProperty(Controller.prototype, "classes", {
4247
+ get: function() {
4248
+ return this.scope.classes;
4249
+ },
4250
+ enumerable: false,
3686
4251
  configurable: true
3687
4252
  });
3688
4253
  Object.defineProperty(Controller.prototype, "data", {
3689
4254
  get: function() {
3690
4255
  return this.scope.data;
3691
4256
  },
3692
- enumerable: true,
4257
+ enumerable: false,
3693
4258
  configurable: true
3694
4259
  });
3695
4260
  Controller.prototype.initialize = function() {};
3696
4261
  Controller.prototype.connect = function() {};
3697
4262
  Controller.prototype.disconnect = function() {};
4263
+ Controller.blessings = [ ClassPropertiesBlessing, TargetPropertiesBlessing, ValuePropertiesBlessing ];
3698
4264
  Controller.targets = [];
4265
+ Controller.values = {};
3699
4266
  return Controller;
3700
4267
  }();
3701
4268