@tko/binding.core 4.0.0-beta1.0 → 4.0.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.
- package/dist/attr.js +10 -14
- package/dist/attr.js.map +2 -2
- package/dist/checked.js +19 -28
- package/dist/checked.js.map +3 -3
- package/dist/click.js +4 -5
- package/dist/click.js.map +2 -2
- package/dist/css.js +6 -12
- package/dist/css.js.map +2 -2
- package/dist/descendantsComplete.js +3 -4
- package/dist/descendantsComplete.js.map +2 -2
- package/dist/enableDisable.js +6 -7
- package/dist/enableDisable.js.map +2 -2
- package/dist/event.js +7 -8
- package/dist/event.js.map +3 -3
- package/dist/hasfocus.js +23 -22
- package/dist/hasfocus.js.map +2 -2
- package/dist/html.js +8 -8
- package/dist/html.js.map +2 -2
- package/dist/index.cjs +1037 -863
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +6 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +2 -2
- package/dist/let.js +6 -7
- package/dist/let.js.map +2 -2
- package/dist/options.js +39 -26
- package/dist/options.js.map +2 -2
- package/dist/selectedOptions.js +8 -9
- package/dist/selectedOptions.js.map +2 -2
- package/dist/style.js +8 -13
- package/dist/style.js.map +2 -2
- package/dist/submit.js +7 -8
- package/dist/submit.js.map +2 -2
- package/dist/text.js +4 -5
- package/dist/text.js.map +2 -2
- package/dist/textInput.js +24 -59
- package/dist/textInput.js.map +2 -2
- package/dist/uniqueName.js +5 -7
- package/dist/uniqueName.js.map +2 -2
- package/dist/using.js +6 -7
- package/dist/using.js.map +2 -2
- package/dist/value.js +17 -23
- package/dist/value.js.map +2 -2
- package/dist/visible.js +7 -8
- package/dist/visible.js.map +2 -2
- package/package.json +6 -7
- package/LICENSE +0 -22
- package/dist/test-helper.js +0 -14
- package/dist/test-helper.js.map +0 -7
package/dist/textInput.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
arrayForEach
|
|
9
|
-
} from "@tko/utils";
|
|
10
|
-
import {
|
|
11
|
-
unwrap
|
|
12
|
-
} from "@tko/observable";
|
|
13
|
-
import {
|
|
14
|
-
BindingHandler
|
|
15
|
-
} from "@tko/bind";
|
|
16
|
-
var parseVersion, operaVersion, safariVersion, firefoxVersion;
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { safeSetTimeout, options, arrayForEach } from "@tko/utils";
|
|
4
|
+
import { unwrap } from "@tko/observable";
|
|
5
|
+
import { BindingHandler } from "@tko/bind";
|
|
6
|
+
export const MSIE_REGEX = /MSIE ([^ ;]+)|rv:([^ )]+)/;
|
|
7
|
+
let operaVersion, safariVersion, firefoxVersion, ieVersion;
|
|
17
8
|
class TextInput extends BindingHandler {
|
|
18
9
|
get aliases() {
|
|
19
10
|
return "textinput";
|
|
@@ -51,6 +42,7 @@ class TextInput extends BindingHandler {
|
|
|
51
42
|
const elementValue = element.value;
|
|
52
43
|
if (this.previousElementValue !== elementValue) {
|
|
53
44
|
if (options.debug && event) {
|
|
45
|
+
;
|
|
54
46
|
element._ko_textInputProcessedEvent = event.type;
|
|
55
47
|
}
|
|
56
48
|
this.previousElementValue = elementValue;
|
|
@@ -61,8 +53,8 @@ class TextInput extends BindingHandler {
|
|
|
61
53
|
const element = this.$element;
|
|
62
54
|
if (!this.timeoutHandle) {
|
|
63
55
|
this.elementValueBeforeEvent = element.value;
|
|
64
|
-
const
|
|
65
|
-
this.timeoutHandle = safeSetTimeout(
|
|
56
|
+
const handler = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel;
|
|
57
|
+
this.timeoutHandle = safeSetTimeout(handler, 4);
|
|
66
58
|
}
|
|
67
59
|
}
|
|
68
60
|
updateView() {
|
|
@@ -80,43 +72,8 @@ class TextInput extends BindingHandler {
|
|
|
80
72
|
}
|
|
81
73
|
}
|
|
82
74
|
class TextInputIE extends TextInput {
|
|
83
|
-
constructor(...args) {
|
|
84
|
-
super(...args);
|
|
85
|
-
if (ieVersion < 11) {
|
|
86
|
-
this.addEventListener("propertychange", (event) => event.propertyName === "value" && this.updateModel(event));
|
|
87
|
-
}
|
|
88
|
-
if (ieVersion >= 8 && ieVersion < 10) {
|
|
89
|
-
this.watchForSelectionChangeEvent();
|
|
90
|
-
this.addEventListener("dragend", "deferUpdateModel");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
75
|
eventsIndicatingSyncValueChange() {
|
|
94
|
-
return [...super.
|
|
95
|
-
}
|
|
96
|
-
selectionChangeHandler(event) {
|
|
97
|
-
const target = this.activeElement;
|
|
98
|
-
const handler2 = target && domData.get(target, selectionChangeHandlerName);
|
|
99
|
-
if (handler2) {
|
|
100
|
-
handler2(event);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
watchForSelectionChangeEvent(element, ieUpdateModel) {
|
|
104
|
-
const ownerDoc = element.ownerDocument;
|
|
105
|
-
if (!domData.get(ownerDoc, selectionChangeRegisteredName)) {
|
|
106
|
-
domData.set(ownerDoc, selectionChangeRegisteredName, true);
|
|
107
|
-
registerEventHandler(ownerDoc, "selectionchange", this.selectionChangeHandler.bind(ownerDoc));
|
|
108
|
-
}
|
|
109
|
-
domData.set(element, selectionChangeHandlerName, handler);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
class TextInputIE9 extends TextInputIE {
|
|
113
|
-
updateModel(...args) {
|
|
114
|
-
this.deferUpdateModel(...args);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
class TextInputIE8 extends TextInputIE {
|
|
118
|
-
eventsIndicatingValueChange() {
|
|
119
|
-
return [...super.eventsIndicatingValueChange(), "keyup", "keydown"];
|
|
76
|
+
return [...super.eventsIndicatingSyncValueChange(), "keypress"];
|
|
120
77
|
}
|
|
121
78
|
}
|
|
122
79
|
class TextInputLegacySafari extends TextInput {
|
|
@@ -133,19 +90,27 @@ class TextInputLegacyFirefox extends TextInput {
|
|
|
133
90
|
eventsIndicatingValueChange() {
|
|
134
91
|
return [
|
|
135
92
|
...super.eventsIndicatingSyncValueChange(),
|
|
93
|
+
// Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete
|
|
136
94
|
"DOMAutoComplete",
|
|
95
|
+
// Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.
|
|
137
96
|
"dragdrop",
|
|
97
|
+
// < 3.5
|
|
138
98
|
"drop"
|
|
99
|
+
// 3.5
|
|
139
100
|
];
|
|
140
101
|
}
|
|
141
102
|
}
|
|
142
103
|
const w = options.global;
|
|
143
104
|
if (w.navigator) {
|
|
144
|
-
const
|
|
105
|
+
const parseVersion = (matches) => matches && parseFloat(matches[1]);
|
|
145
106
|
const userAgent = w.navigator.userAgent;
|
|
146
107
|
const isChrome = userAgent.match(/Chrome\/([^ ]+)/);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
108
|
+
if (!isChrome) {
|
|
109
|
+
operaVersion = w.opera && w.opera.version && parseInt(w.opera.version());
|
|
110
|
+
safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/));
|
|
111
|
+
firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]*)/));
|
|
112
|
+
const ieMatch = userAgent.match(MSIE_REGEX);
|
|
113
|
+
ieVersion = ieMatch && (parseFloat(ieMatch[1]) || parseFloat(ieMatch[2]));
|
|
114
|
+
}
|
|
150
115
|
}
|
|
151
|
-
export const textInput = ieVersion
|
|
116
|
+
export const textInput = ieVersion && ieVersion <= 11 ? TextInputIE : safariVersion && safariVersion < 5 ? TextInputLegacySafari : operaVersion && operaVersion < 11 ? TextInputLegacyOpera : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox : TextInput;
|
package/dist/textInput.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/textInput.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { safeSetTimeout, options, arrayForEach } from '@tko/utils'\n\nimport { unwrap } from '@tko/observable'\n\nimport { BindingHandler } from '@tko/bind'\n\nexport const MSIE_REGEX = /MSIE ([^ ;]+)|rv:([^ )]+)/\n\nlet operaVersion, safariVersion, firefoxVersion, ieVersion\n\n/**\n * TextInput binding handler for modern browsers (legacy below).\n * @extends BindingHandler\n */\nclass TextInput extends BindingHandler {\n get aliases() {\n return 'textinput'\n }\n\n override $element: HTMLInputElement\n previousElementValue: any\n elementValueBeforeEvent?: ReturnType<typeof setTimeout>\n timeoutHandle?: ReturnType<typeof setTimeout>\n\n constructor(...args: [any]) {\n super(...args)\n this.previousElementValue = this.$element.value\n\n if (options.debug && (this.constructor as any)._forceUpdateOn) {\n // Provide a way for tests to specify exactly which events are bound\n arrayForEach((this.constructor as any)._forceUpdateOn, eventName => {\n if (eventName.slice(0, 5) === 'after') {\n this.addEventListener(eventName.slice(5), 'deferUpdateModel')\n } else {\n this.addEventListener(eventName, 'updateModel')\n }\n })\n }\n\n for (const eventName of this.eventsIndicatingSyncValueChange()) {\n this.addEventListener(eventName, 'updateModel')\n }\n for (const eventName of this.eventsIndicatingDeferValueChange()) {\n this.addEventListener(eventName, 'deferUpdateModel')\n }\n this.computed('updateView')\n }\n\n eventsIndicatingSyncValueChange() {\n // input: Default, modern handler\n // change: Catch programmatic updates of the value that fire this event.\n // blur: To deal with browsers that don't notify any kind of event for some changes (IE, Safari, etc.)\n return ['input', 'change', 'blur']\n }\n\n eventsIndicatingDeferValueChange(): any[] {\n return []\n }\n\n updateModel(event) {\n const element = this.$element\n clearTimeout(this.timeoutHandle)\n this.elementValueBeforeEvent = this.timeoutHandle = undefined\n const elementValue = element.value\n if (this.previousElementValue !== elementValue) {\n // Provide a way for tests to know exactly which event was processed\n if (options.debug && event) {\n ;(element as any)._ko_textInputProcessedEvent = event.type\n }\n this.previousElementValue = elementValue\n this.value = elementValue\n }\n }\n\n deferUpdateModel(event: any) {\n const element = this.$element\n if (!this.timeoutHandle) {\n // The elementValueBeforeEvent variable is set *only* during the brief gap between an\n // event firing and the updateModel function running. This allows us to ignore model\n // updates that are from the previous state of the element, usually due to techniques\n // such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.\n this.elementValueBeforeEvent = element.value as any\n const handler = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel\n this.timeoutHandle = safeSetTimeout(handler, 4)\n }\n }\n\n updateView() {\n let modelValue = unwrap(this.value)\n if (modelValue === null || modelValue === undefined) {\n modelValue = ''\n }\n if (this.elementValueBeforeEvent !== undefined && modelValue === this.elementValueBeforeEvent) {\n setTimeout(this.updateView.bind(this), 4)\n } else if (this.$element.value !== modelValue) {\n // Update the element only if the element and model are different. On some browsers, updating the value\n // will move the cursor to the end of the input, which would be bad while the user is typing.\n this.previousElementValue = modelValue // Make sure we ignore events (propertychange) that result from updating the value\n this.$element.value = modelValue\n this.previousElementValue = this.$element.value // In case the browser changes the value (see #2281)\n }\n }\n}\n\nclass TextInputIE extends TextInput {\n override eventsIndicatingSyncValueChange() {\n //keypress: All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed\n return [...super.eventsIndicatingSyncValueChange(), 'keypress']\n }\n}\n\n// Safari <5 doesn't fire the 'input' event for <textarea> elements (it does fire 'textInput'\n// but only when typing). So we'll just catch as much as we can with keydown, cut, and paste.\nclass TextInputLegacySafari extends TextInput {\n override eventsIndicatingDeferValueChange() {\n return ['keydown', 'paste', 'cut']\n }\n}\n\nclass TextInputLegacyOpera extends TextInput {\n override eventsIndicatingDeferValueChange(): string[] {\n // Opera 10 doesn't always fire the 'input' event for cut, paste, undo & drop operations.\n // We can try to catch some of those using 'keydown'.\n return ['keydown']\n }\n}\n\nclass TextInputLegacyFirefox extends TextInput {\n eventsIndicatingValueChange(): string[] {\n return [\n ...super.eventsIndicatingSyncValueChange(),\n // Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete\n 'DOMAutoComplete',\n // Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.\n 'dragdrop', // < 3.5\n 'drop' // 3.5\n ]\n }\n}\n\nconst w = options.global // window / global\nif (w.navigator) {\n const parseVersion = matches => matches && parseFloat(matches[1])\n const userAgent = w.navigator.userAgent\n const isChrome = userAgent.match(/Chrome\\/([^ ]+)/)\n if (!isChrome) {\n // Detect various browser versions because some old versions don't fully support the 'input' event\n operaVersion = w.opera && w.opera.version && parseInt(w.opera.version())\n safariVersion = parseVersion(userAgent.match(/Version\\/([^ ]+) Safari/))\n firefoxVersion = parseVersion(userAgent.match(/Firefox\\/([^ ]*)/))\n const ieMatch = userAgent.match(MSIE_REGEX)\n ieVersion = ieMatch && (parseFloat(ieMatch[1]) || parseFloat(ieMatch[2]))\n }\n}\n\nexport const textInput =\n ieVersion && ieVersion <= 11\n ? TextInputIE\n : safariVersion && safariVersion < 5\n ? TextInputLegacySafari\n : operaVersion && operaVersion < 11\n ? TextInputLegacyOpera\n : firefoxVersion && firefoxVersion < 4\n ? TextInputLegacyFirefox\n : TextInput\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,gBAAgB,SAAS,oBAAoB;AAEtD,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAExB,aAAM,aAAa;AAE1B,IAAI,cAAc,eAAe,gBAAgB;AAMjD,MAAM,kBAAkB,eAAe;AAAA,EACrC,IAAI,UAAU;AACZ,WAAO;AAAA,EACT;AAAA,EAOA,eAAe,MAAa;AAC1B,UAAM,GAAG,IAAI;AACb,SAAK,uBAAuB,KAAK,SAAS;AAE1C,QAAI,QAAQ,SAAU,KAAK,YAAoB,gBAAgB;AAE7D,mBAAc,KAAK,YAAoB,gBAAgB,eAAa;AAClE,YAAI,UAAU,MAAM,GAAG,CAAC,MAAM,SAAS;AACrC,eAAK,iBAA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eAAe,KAC7B,uBACA,kBAAkB,iBAAiB,IACjC,yBACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/uniqueName.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "@tko/utils";
|
|
5
|
-
export var uniqueName = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
export const uniqueName = {
|
|
6
4
|
init: function(element, valueAccessor) {
|
|
7
5
|
if (valueAccessor()) {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const name = "ko_unique_" + ++uniqueName.currentIndex;
|
|
7
|
+
element.name = name;
|
|
10
8
|
}
|
|
11
9
|
},
|
|
12
10
|
currentIndex: 0
|
package/dist/uniqueName.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/uniqueName.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export const uniqueName = {\n init: function (element, valueAccessor) {\n if (valueAccessor()) {\n const name = 'ko_unique_' + ++uniqueName.currentIndex\n element.name = name\n }\n },\n currentIndex: 0\n}\n"],
|
|
5
|
+
"mappings": ";;AAAO,aAAM,aAAa;AAAA,EACxB,MAAM,SAAU,SAAS,eAAe;AACtC,QAAI,cAAc,GAAG;AACnB,YAAM,OAAO,eAAe,EAAE,WAAW;AACzC,cAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EACA,cAAc;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/using.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var innerContext = bindingContext.createChildContext(valueAccessor);
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { applyBindingsToDescendants } from "@tko/bind";
|
|
4
|
+
export const using = {
|
|
5
|
+
init: function(element, valueAccessor, _allBindings, _viewModel, bindingContext) {
|
|
6
|
+
const innerContext = bindingContext.createChildContext(valueAccessor);
|
|
8
7
|
applyBindingsToDescendants(innerContext, element);
|
|
9
8
|
return { controlsDescendantBindings: true };
|
|
10
9
|
},
|
package/dist/using.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/using.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { applyBindingsToDescendants } from '@tko/bind'\n\nimport type { BindingContext, AllBindings } from '@tko/bind'\n\nexport const using = {\n init: function (element, valueAccessor, _allBindings: AllBindings, _viewModel, bindingContext: BindingContext) {\n const innerContext = bindingContext.createChildContext(valueAccessor)\n applyBindingsToDescendants(innerContext, element)\n return { controlsDescendantBindings: true }\n },\n allowVirtualElements: true\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,kCAAkC;AAIpC,aAAM,QAAQ;AAAA,EACnB,MAAM,SAAU,SAAS,eAAe,cAA2B,YAAY,gBAAgC;AAC7G,UAAM,eAAe,eAAe,mBAAmB,aAAa;AACpE,+BAA2B,cAAc,OAAO;AAChD,WAAO,EAAE,4BAA4B,KAAK;AAAA,EAC5C;AAAA,EACA,sBAAsB;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/value.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
arrayForEach,
|
|
8
|
-
selectExtensions
|
|
9
|
-
} from "@tko/utils";
|
|
10
|
-
import {
|
|
11
|
-
unwrap,
|
|
12
|
-
dependencyDetection
|
|
13
|
-
} from "@tko/observable";
|
|
14
|
-
import {
|
|
15
|
-
applyBindingAccessorsToNode,
|
|
16
|
-
BindingHandler
|
|
17
|
-
} from "@tko/bind";
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { stringStartsWith, safeSetTimeout, tagNameLower, arrayForEach, selectExtensions } from "@tko/utils";
|
|
4
|
+
import { unwrap, dependencyDetection } from "@tko/observable";
|
|
5
|
+
import { applyBindingAccessorsToNode, BindingHandler } from "@tko/bind";
|
|
6
|
+
import { MSIE_REGEX } from "./textInput";
|
|
18
7
|
export class value extends BindingHandler {
|
|
19
8
|
static get after() {
|
|
20
9
|
return ["options", "foreach", "template"];
|
|
@@ -52,8 +41,10 @@ export class value extends BindingHandler {
|
|
|
52
41
|
const e = this.$element;
|
|
53
42
|
return this.isInput && (e.type == "checkbox" || e.type == "radio");
|
|
54
43
|
}
|
|
44
|
+
// Workaround for https://github.com/SteveSanderson/knockout/issues/122
|
|
45
|
+
// IE doesn't fire "change" events on textboxes if the user selects a value from its autocomplete list
|
|
55
46
|
get ieAutoCompleteHackNeeded() {
|
|
56
|
-
return
|
|
47
|
+
return this.isInput && this.$element.type == "text" && this.$element.autocomplete != "off" && (!this.$element.form || this.$element.form.autocomplete != "off") && MSIE_REGEX.test(window.navigator.userAgent);
|
|
57
48
|
}
|
|
58
49
|
valueUpdateHandler() {
|
|
59
50
|
this.elementValueBeforeEvent = null;
|
|
@@ -61,18 +52,21 @@ export class value extends BindingHandler {
|
|
|
61
52
|
this.value = selectExtensions.readValue(this.$element);
|
|
62
53
|
}
|
|
63
54
|
registerEvent(eventName) {
|
|
64
|
-
|
|
55
|
+
let handler = this.valueUpdateHandler.bind(this);
|
|
65
56
|
if (stringStartsWith(eventName, "after")) {
|
|
66
57
|
handler = () => {
|
|
67
58
|
this.elementValueBeforeEvent = selectExtensions.readValue(this.$element);
|
|
68
59
|
safeSetTimeout(this.valueUpdateHandler.bind(this), 0);
|
|
69
60
|
};
|
|
70
|
-
eventName = eventName.substring(
|
|
61
|
+
eventName = eventName.substring(
|
|
62
|
+
5
|
|
63
|
+
/* 'after'.length */
|
|
64
|
+
);
|
|
71
65
|
}
|
|
72
66
|
this.addEventListener(eventName, handler);
|
|
73
67
|
}
|
|
74
68
|
updateFromModelForFile() {
|
|
75
|
-
|
|
69
|
+
const newValue = unwrap(this.value);
|
|
76
70
|
if (newValue === null || newValue === void 0 || newValue === "") {
|
|
77
71
|
this.$element.value = "";
|
|
78
72
|
} else {
|
|
@@ -81,8 +75,8 @@ export class value extends BindingHandler {
|
|
|
81
75
|
}
|
|
82
76
|
updateFromModelForValue() {
|
|
83
77
|
const element = this.$element;
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
const newValue = unwrap(this.value);
|
|
79
|
+
const elementValue = selectExtensions.readValue(element);
|
|
86
80
|
if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {
|
|
87
81
|
safeSetTimeout(this.updateFromModel.bind(this), 0);
|
|
88
82
|
return;
|
package/dist/value.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/value.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { stringStartsWith, safeSetTimeout, tagNameLower, arrayForEach, selectExtensions } from '@tko/utils'\n\nimport { unwrap, dependencyDetection } from '@tko/observable'\n\nimport { applyBindingAccessorsToNode, BindingHandler } from '@tko/bind'\n\nimport { MSIE_REGEX } from './textInput'\n\nexport class value extends BindingHandler {\n static get after() {\n return ['options', 'foreach', 'template']\n }\n\n override $element: HTMLInputElement\n elementValueBeforeEvent: any\n propertyChangeFired: any\n propertyChangedFired: boolean\n updateFromModel: any\n constructor(...args: [any]) {\n super(...args)\n\n // If the value binding is placed on a radio/checkbox, then just pass through to checkedValue and quit\n if (this.isCheckboxOrRadio) {\n applyBindingAccessorsToNode(this.$element, { checkedValue: this.valueAccessor })\n return\n }\n\n this.propertyChangedFired = false\n this.elementValueBeforeEvent = null\n\n if (this.ieAutoCompleteHackNeeded) {\n this.addEventListener('propertyChange', () => (this.propertyChangedFired = true))\n this.addEventListener('focus', () => (this.propertyChangedFired = false))\n this.addEventListener('blur', () => this.propertyChangeFired && this.valueUpdateHandler())\n }\n\n arrayForEach(this.eventsToCatch, eventName => this.registerEvent(eventName))\n\n if (this.isInput && this.$element.type === 'file') {\n this.updateFromModel = this.updateFromModelForFile\n } else {\n this.updateFromModel = this.updateFromModelForValue\n }\n\n this.computed('updateFromModel')\n }\n\n get eventsToCatch() {\n const requestedEventsToCatch = this.allBindings.get('valueUpdate')\n const requestedEventsArray =\n typeof requestedEventsToCatch === 'string' ? [requestedEventsToCatch] : requestedEventsToCatch || []\n return [...new Set(['change', ...requestedEventsArray])]\n }\n\n get isInput() {\n return tagNameLower(this.$element) === 'input'\n }\n\n get isCheckboxOrRadio() {\n const e = this.$element\n return this.isInput && (e.type == 'checkbox' || e.type == 'radio')\n }\n\n // Workaround for https://github.com/SteveSanderson/knockout/issues/122\n // IE doesn't fire \"change\" events on textboxes if the user selects a value from its autocomplete list\n get ieAutoCompleteHackNeeded() {\n return (\n this.isInput\n && this.$element.type == 'text'\n && this.$element.autocomplete != 'off'\n && (!this.$element.form || this.$element.form.autocomplete != 'off')\n && MSIE_REGEX.test(window.navigator.userAgent) //IE detection (primarily for IE10/11)\n )\n }\n\n valueUpdateHandler() {\n this.elementValueBeforeEvent = null\n this.propertyChangedFired = false\n this.value = selectExtensions.readValue(this.$element)\n }\n\n registerEvent(eventName) {\n // The syntax \"after<eventname>\" means \"run the handler asynchronously after the event\"\n // This is useful, for example, to catch \"keydown\" events after the browser has updated the control\n // (otherwise, selectExtensions.readValue(this) will receive the control's value *before* the key event)\n let handler = this.valueUpdateHandler.bind(this)\n if (stringStartsWith(eventName, 'after')) {\n handler = () => {\n // The elementValueBeforeEvent variable is non-null *only* during the brief gap between\n // a keyX event firing and the valueUpdateHandler running, which is scheduled to happen\n // at the earliest asynchronous opportunity. We store this temporary information so that\n // if, between keyX and valueUpdateHandler, the underlying model value changes separately,\n // we can overwrite that model value change with the value the user just typed. Otherwise,\n // techniques like rateLimit can trigger model changes at critical moments that will\n // override the user's inputs, causing keystrokes to be lost.\n this.elementValueBeforeEvent = selectExtensions.readValue(this.$element)\n safeSetTimeout(this.valueUpdateHandler.bind(this), 0)\n }\n eventName = eventName.substring(5 /* 'after'.length */)\n }\n this.addEventListener(eventName, handler)\n }\n\n updateFromModelForFile() {\n // For file input elements, can only write the empty string\n const newValue = unwrap(this.value)\n if (newValue === null || newValue === undefined || newValue === '') {\n this.$element.value = ''\n } else {\n dependencyDetection.ignore(this.valueUpdateHandler, this) // reset the model to match the element\n }\n }\n\n updateFromModelForValue() {\n const element = this.$element\n const newValue = unwrap(this.value)\n const elementValue = selectExtensions.readValue(element)\n\n if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {\n safeSetTimeout(this.updateFromModel.bind(this), 0)\n return\n }\n\n if (newValue === elementValue && elementValue !== undefined) {\n return\n }\n\n if (tagNameLower(element) === 'select') {\n const allowUnset = this.allBindings.get('valueAllowUnset')\n selectExtensions.writeValue(element, newValue, allowUnset)\n\n if (!allowUnset && newValue !== selectExtensions.readValue(element)) {\n // If you try to set a model value that can't be represented in an already-populated dropdown, reject that change,\n // because you're not allowed to have a model value that disagrees with a visible UI selection.\n dependencyDetection.ignore(this.valueUpdateHandler, this)\n }\n } else {\n selectExtensions.writeValue(element, newValue)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,kBAAkB,gBAAgB,cAAc,cAAc,wBAAwB;AAE/F,SAAS,QAAQ,2BAA2B;AAE5C,SAAS,6BAA6B,sBAAsB;AAE5D,SAAS,kBAAkB;AAEpB,aAA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UAAU,UAAU;AAEzD,UAAI,CAAC,cAAc,aAAa,iBAAiB,UAAU,OAAO,GAAG;AAGnE,4BAAoB,OAAO,KAAK,oBAAoB,IAAI;AAAA,MAC1D;AAAA,IACF,OAAO;AACL,uBAAiB,WAAW,SAAS,QAAQ;AAAA,IAC/C;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/visible.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export var visible = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { unwrap } from "@tko/observable";
|
|
4
|
+
export const visible = {
|
|
6
5
|
update: function(element, valueAccessor) {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const value = unwrap(valueAccessor());
|
|
7
|
+
const isCurrentlyVisible = !(element.style.display === "none");
|
|
9
8
|
if (value && !isCurrentlyVisible) {
|
|
10
9
|
element.style.display = "";
|
|
11
10
|
} else if (!value && isCurrentlyVisible) {
|
|
@@ -13,7 +12,7 @@ export var visible = {
|
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
export
|
|
15
|
+
export const hidden = {
|
|
17
16
|
update: function(element, valueAccessor) {
|
|
18
17
|
visible.update.call(this, element, () => !unwrap(valueAccessor()));
|
|
19
18
|
}
|
package/dist/visible.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/visible.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { unwrap } from '@tko/observable'\n\nexport const visible = {\n update: function (element, valueAccessor) {\n const value = unwrap(valueAccessor())\n const isCurrentlyVisible = !(element.style.display === 'none')\n if (value && !isCurrentlyVisible) {\n element.style.display = ''\n } else if (!value && isCurrentlyVisible) {\n element.style.display = 'none'\n }\n }\n}\n\nexport const hidden = {\n update: function (element, valueAccessor) {\n visible.update.call(this, element, () => !unwrap(valueAccessor()))\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,cAAc;AAEhB,aAAM,UAAU;AAAA,EACrB,QAAQ,SAAU,SAAS,eAAe;AACxC,UAAM,QAAQ,OAAO,cAAc,CAAC;AACpC,UAAM,qBAAqB,EAAE,QAAQ,MAAM,YAAY;AACvD,QAAI,SAAS,CAAC,oBAAoB;AAChC,cAAQ,MAAM,UAAU;AAAA,IAC1B,WAAW,CAAC,SAAS,oBAAoB;AACvC,cAAQ,MAAM,UAAU;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,aAAM,SAAS;AAAA,EACpB,QAAQ,SAAU,SAAS,eAAe;AACxC,YAAQ,OAAO,KAAK,MAAM,SAAS,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAAA,EACnE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0
|
|
2
|
+
"version": "4.0.0",
|
|
3
3
|
"name": "@tko/binding.core",
|
|
4
4
|
"description": "TKO Core bindings",
|
|
5
5
|
"module": "dist/binding.core.js",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://tko.io",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tko/bind": "^4.0.0
|
|
27
|
-
"@tko/computed": "^4.0.0
|
|
28
|
-
"@tko/observable": "^4.0.0
|
|
29
|
-
"@tko/utils": "^4.0.0
|
|
26
|
+
"@tko/bind": "^4.0.0",
|
|
27
|
+
"@tko/computed": "^4.0.0",
|
|
28
|
+
"@tko/observable": "^4.0.0",
|
|
29
|
+
"@tko/utils": "^4.0.0",
|
|
30
30
|
"tslib": "^2.2.0"
|
|
31
31
|
},
|
|
32
32
|
"karma": {
|
|
@@ -46,6 +46,5 @@
|
|
|
46
46
|
"import": "./dist/index.js"
|
|
47
47
|
},
|
|
48
48
|
"./helpers/*": "./helpers/*"
|
|
49
|
-
}
|
|
50
|
-
"gitHead": "99114c4deded3fc5dbddd5c7c9c63c845a18263b"
|
|
49
|
+
}
|
|
51
50
|
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
|
|
2
|
-
|
|
3
|
-
Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
|
|
4
|
-
http://knockoutjs.com/
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in
|
|
14
|
-
all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
-
THE SOFTWARE.
|
package/dist/test-helper.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0-beta1.0 ESM
|
|
2
|
-
import {
|
|
3
|
-
arrayFilter,
|
|
4
|
-
arrayMap,
|
|
5
|
-
selectExtensions
|
|
6
|
-
} from "@tko/utils";
|
|
7
|
-
export var matchers = {
|
|
8
|
-
toHaveSelectedValues(expectedValues) {
|
|
9
|
-
const selectedNodes = arrayFilter(this.actual.childNodes, (node) => node.selected);
|
|
10
|
-
const selectedValues = arrayMap(selectedNodes, (node) => selectExtensions.readValue(node));
|
|
11
|
-
this.actual = selectedValues;
|
|
12
|
-
return this.env.equals_(selectedValues, expectedValues);
|
|
13
|
-
}
|
|
14
|
-
};
|
package/dist/test-helper.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/test-helper.ts"],
|
|
4
|
-
"sourcesContent": ["\nimport {\n arrayFilter, arrayMap, selectExtensions\n} from '@tko/utils'\n\n/**\n * Note that these matchers cannot be included in jasmine-13-helpers.js.\n *\n * When using Rollup to create the tests, it creates multiple files e.g.\n * - optionsBehaviors\n * - checkedBehaviors\n * - ...\n *\n * This is problematic if domData access is imported via jasmine-13-helper,\n * since there'll be only one instance of domData imported i.e. the imports\n * should look like this:\n *\n * - optionsBehaviors\n * - utils/dom/data\n * - checkedBehaviors\n * - utils/dom/data/\n *\n * But what happens is that the singleton in data.js (dataStore) is created\n * in jasmine-13-helper, so when it's referenced it always comes from\n * the very first import. So in checkedBehaviors any reference to domData\n * would get it from the `dataStore` in optionsBehaviors (because it was\n * imported first).\n *\n * Or at least that seems to be the dragon here.\n */\n\nexport var matchers = {\n toHaveSelectedValues (expectedValues) {\n const selectedNodes = arrayFilter(this.actual.childNodes, node => node.selected)\n const selectedValues = arrayMap(selectedNodes, node => selectExtensions.readValue(node))\n this.actual = selectedValues // Fix explanatory message\n return this.env.equals_(selectedValues, expectedValues)\n }\n}\n"],
|
|
5
|
-
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AA8BO,WAAI,WAAW;AAAA,EACpB,qBAAsB,gBAAgB;AACpC,UAAM,gBAAgB,YAAY,KAAK,OAAO,YAAY,UAAQ,KAAK,QAAQ;AAC/E,UAAM,iBAAiB,SAAS,eAAe,UAAQ,iBAAiB,UAAU,IAAI,CAAC;AACvF,SAAK,SAAS;AACd,WAAO,KAAK,IAAI,QAAQ,gBAAgB,cAAc;AAAA,EACxD;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|