@multiplatform.one/forms 7.41.0 → 7.43.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/cjs/Chip/index.cjs +5 -2
- package/dist/cjs/Chip/index.native.js +2 -1
- package/dist/cjs/Chip/index.native.js.map +1 -1
- package/dist/cjs/Form/index.cjs +25 -22
- package/dist/cjs/Form/index.native.js +27 -24
- package/dist/cjs/Form/index.native.js.map +1 -1
- package/dist/cjs/InputParts/index.cjs +18 -7
- package/dist/cjs/InputParts/index.native.js +18 -7
- package/dist/cjs/InputParts/index.native.js.map +1 -1
- package/dist/cjs/fields/Input/index.cjs +40 -23
- package/dist/cjs/fields/Input/index.native.js +42 -25
- package/dist/cjs/fields/Input/index.native.js.map +1 -1
- package/dist/cjs/fields/SearchInput/index.cjs +5 -2
- package/dist/cjs/fields/SearchInput/index.native.js +2 -1
- package/dist/cjs/fields/SearchInput/index.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/index.native.js +7 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/keyboard/KeyboardDoneBar.cjs +30 -0
- package/dist/cjs/keyboard/KeyboardDoneBar.native.js +65 -0
- package/dist/cjs/keyboard/KeyboardDoneBar.native.js.map +1 -0
- package/dist/cjs/keyboard/chain.cjs +106 -0
- package/dist/cjs/keyboard/chain.native.js +203 -0
- package/dist/cjs/keyboard/chain.native.js.map +1 -0
- package/dist/cjs/keyboard/index.cjs +35 -0
- package/dist/cjs/keyboard/index.native.js +38 -0
- package/dist/cjs/keyboard/index.native.js.map +1 -0
- package/dist/cjs/keyboard/types.cjs +18 -0
- package/dist/cjs/keyboard/types.native.js +21 -0
- package/dist/cjs/keyboard/types.native.js.map +1 -0
- package/dist/cjs/keyboard/useKeyboardChain.cjs +33 -0
- package/dist/cjs/keyboard/useKeyboardChain.native.js +114 -0
- package/dist/cjs/keyboard/useKeyboardChain.native.js.map +1 -0
- package/dist/cjs/shared/nativeAutoFocus.cjs +37 -0
- package/dist/cjs/shared/nativeAutoFocus.native.js +41 -0
- package/dist/cjs/shared/nativeAutoFocus.native.js.map +1 -0
- package/dist/cjs/themedPrimitives.cjs +2 -0
- package/dist/cjs/themedPrimitives.native.js +2 -0
- package/dist/cjs/themedPrimitives.native.js.map +1 -1
- package/dist/esm/Chip/index.mjs +5 -2
- package/dist/esm/Chip/index.mjs.map +1 -1
- package/dist/esm/Chip/index.native.js +2 -1
- package/dist/esm/Chip/index.native.js.map +1 -1
- package/dist/esm/Form/index.mjs +25 -22
- package/dist/esm/Form/index.mjs.map +1 -1
- package/dist/esm/Form/index.native.js +27 -24
- package/dist/esm/Form/index.native.js.map +1 -1
- package/dist/esm/InputParts/index.mjs +18 -7
- package/dist/esm/InputParts/index.mjs.map +1 -1
- package/dist/esm/InputParts/index.native.js +18 -7
- package/dist/esm/InputParts/index.native.js.map +1 -1
- package/dist/esm/fields/Input/index.mjs +41 -24
- package/dist/esm/fields/Input/index.mjs.map +1 -1
- package/dist/esm/fields/Input/index.native.js +43 -26
- package/dist/esm/fields/Input/index.native.js.map +1 -1
- package/dist/esm/fields/SearchInput/index.mjs +5 -2
- package/dist/esm/fields/SearchInput/index.mjs.map +1 -1
- package/dist/esm/fields/SearchInput/index.native.js +2 -1
- package/dist/esm/fields/SearchInput/index.native.js.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/keyboard/KeyboardDoneBar.mjs +5 -0
- package/dist/esm/keyboard/KeyboardDoneBar.mjs.map +1 -0
- package/dist/esm/keyboard/KeyboardDoneBar.native.js +37 -0
- package/dist/esm/keyboard/KeyboardDoneBar.native.js.map +1 -0
- package/dist/esm/keyboard/chain.mjs +78 -0
- package/dist/esm/keyboard/chain.mjs.map +1 -0
- package/dist/esm/keyboard/chain.native.js +172 -0
- package/dist/esm/keyboard/chain.native.js.map +1 -0
- package/dist/esm/keyboard/index.mjs +5 -0
- package/dist/esm/keyboard/index.mjs.map +1 -0
- package/dist/esm/keyboard/index.native.js +5 -0
- package/dist/esm/keyboard/index.native.js.map +1 -0
- package/dist/esm/keyboard/types.mjs +2 -0
- package/dist/esm/keyboard/types.mjs.map +1 -0
- package/dist/esm/keyboard/types.native.js +2 -0
- package/dist/esm/keyboard/types.native.js.map +1 -0
- package/dist/esm/keyboard/useKeyboardChain.mjs +8 -0
- package/dist/esm/keyboard/useKeyboardChain.mjs.map +1 -0
- package/dist/esm/keyboard/useKeyboardChain.native.js +86 -0
- package/dist/esm/keyboard/useKeyboardChain.native.js.map +1 -0
- package/dist/esm/shared/nativeAutoFocus.mjs +12 -0
- package/dist/esm/shared/nativeAutoFocus.mjs.map +1 -0
- package/dist/esm/shared/nativeAutoFocus.native.js +13 -0
- package/dist/esm/shared/nativeAutoFocus.native.js.map +1 -0
- package/dist/esm/themedPrimitives.mjs +2 -0
- package/dist/esm/themedPrimitives.mjs.map +1 -1
- package/dist/esm/themedPrimitives.native.js +2 -0
- package/dist/esm/themedPrimitives.native.js.map +1 -1
- package/dist/jsx/Chip/index.mjs +5 -2
- package/dist/jsx/Chip/index.mjs.map +1 -1
- package/dist/jsx/Chip/index.native.js +2 -1
- package/dist/jsx/Chip/index.native.js.map +1 -1
- package/dist/jsx/Form/index.mjs +25 -22
- package/dist/jsx/Form/index.mjs.map +1 -1
- package/dist/jsx/Form/index.native.js +27 -24
- package/dist/jsx/Form/index.native.js.map +1 -1
- package/dist/jsx/InputParts/index.mjs +18 -7
- package/dist/jsx/InputParts/index.mjs.map +1 -1
- package/dist/jsx/InputParts/index.native.js +18 -7
- package/dist/jsx/InputParts/index.native.js.map +1 -1
- package/dist/jsx/fields/Input/index.mjs +41 -24
- package/dist/jsx/fields/Input/index.mjs.map +1 -1
- package/dist/jsx/fields/Input/index.native.js +42 -25
- package/dist/jsx/fields/Input/index.native.js.map +1 -1
- package/dist/jsx/fields/SearchInput/index.mjs +5 -2
- package/dist/jsx/fields/SearchInput/index.mjs.map +1 -1
- package/dist/jsx/fields/SearchInput/index.native.js +2 -1
- package/dist/jsx/fields/SearchInput/index.native.js.map +1 -1
- package/dist/jsx/index.js +2 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +7 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/keyboard/KeyboardDoneBar.mjs +5 -0
- package/dist/jsx/keyboard/KeyboardDoneBar.mjs.map +1 -0
- package/dist/jsx/keyboard/KeyboardDoneBar.native.js +65 -0
- package/dist/jsx/keyboard/KeyboardDoneBar.native.js.map +1 -0
- package/dist/jsx/keyboard/chain.mjs +78 -0
- package/dist/jsx/keyboard/chain.mjs.map +1 -0
- package/dist/jsx/keyboard/chain.native.js +203 -0
- package/dist/jsx/keyboard/chain.native.js.map +1 -0
- package/dist/jsx/keyboard/index.mjs +5 -0
- package/dist/jsx/keyboard/index.mjs.map +1 -0
- package/dist/jsx/keyboard/index.native.js +38 -0
- package/dist/jsx/keyboard/index.native.js.map +1 -0
- package/dist/jsx/keyboard/types.mjs +2 -0
- package/dist/jsx/keyboard/types.mjs.map +1 -0
- package/dist/jsx/keyboard/types.native.js +21 -0
- package/dist/jsx/keyboard/types.native.js.map +1 -0
- package/dist/jsx/keyboard/useKeyboardChain.mjs +8 -0
- package/dist/jsx/keyboard/useKeyboardChain.mjs.map +1 -0
- package/dist/jsx/keyboard/useKeyboardChain.native.js +114 -0
- package/dist/jsx/keyboard/useKeyboardChain.native.js.map +1 -0
- package/dist/jsx/shared/nativeAutoFocus.mjs +12 -0
- package/dist/jsx/shared/nativeAutoFocus.mjs.map +1 -0
- package/dist/jsx/shared/nativeAutoFocus.native.js +41 -0
- package/dist/jsx/shared/nativeAutoFocus.native.js.map +1 -0
- package/dist/jsx/themedPrimitives.mjs +2 -0
- package/dist/jsx/themedPrimitives.mjs.map +1 -1
- package/dist/jsx/themedPrimitives.native.js +2 -0
- package/dist/jsx/themedPrimitives.native.js.map +1 -1
- package/package.json +8 -8
- package/src/Button/Button.disabledReasonInk.spec.tsx +7 -1
- package/src/Chip/index.tsx +2 -1
- package/src/Form/index.tsx +31 -26
- package/src/InputParts/index.tsx +22 -12
- package/src/fields/Input/index.tsx +53 -31
- package/src/fields/SearchInput/SearchInput.focusHold.native.spec.tsx +81 -0
- package/src/fields/SearchInput/index.tsx +2 -1
- package/src/index.ts +17 -0
- package/src/keyboard/KeyboardDoneBar.native.tsx +38 -0
- package/src/keyboard/KeyboardDoneBar.tsx +6 -0
- package/src/keyboard/chain.spec.ts +98 -0
- package/src/keyboard/chain.tsx +115 -0
- package/src/keyboard/index.ts +5 -0
- package/src/keyboard/types.ts +21 -0
- package/src/keyboard/useKeyboardChain.native.tsx +79 -0
- package/src/keyboard/useKeyboardChain.ts +6 -0
- package/src/shared/nativeAutoFocus.ts +20 -0
- package/src/themedPrimitives.tsx +9 -1
- package/types/Chip/index.d.ts.map +1 -1
- package/types/Form/index.d.ts.map +1 -1
- package/types/InputParts/index.d.ts.map +1 -1
- package/types/fields/Input/index.d.ts.map +1 -1
- package/types/fields/SearchInput/index.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/keyboard/KeyboardDoneBar.d.ts +4 -0
- package/types/keyboard/KeyboardDoneBar.d.ts.map +1 -0
- package/types/keyboard/KeyboardDoneBar.native.d.ts +8 -0
- package/types/keyboard/KeyboardDoneBar.native.d.ts.map +1 -0
- package/types/keyboard/chain.d.ts +48 -0
- package/types/keyboard/chain.d.ts.map +1 -0
- package/types/keyboard/index.d.ts +6 -0
- package/types/keyboard/index.d.ts.map +1 -0
- package/types/keyboard/types.d.ts +19 -0
- package/types/keyboard/types.d.ts.map +1 -0
- package/types/keyboard/useKeyboardChain.d.ts +4 -0
- package/types/keyboard/useKeyboardChain.d.ts.map +1 -0
- package/types/keyboard/useKeyboardChain.native.d.ts +3 -0
- package/types/keyboard/useKeyboardChain.native.d.ts.map +1 -0
- package/types/shared/nativeAutoFocus.d.ts +13 -0
- package/types/shared/nativeAutoFocus.d.ts.map +1 -0
- package/types/themedPrimitives.d.ts.map +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var chain_exports = {};
|
|
24
|
+
__export(chain_exports, {
|
|
25
|
+
KeyboardChain: () => KeyboardChain,
|
|
26
|
+
KeyboardChainContext: () => KeyboardChainContext,
|
|
27
|
+
KeyboardChainScope: () => KeyboardChainScope,
|
|
28
|
+
readingOrder: () => readingOrder
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(chain_exports);
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
function readingOrder(boxes) {
|
|
34
|
+
return boxes.filter(box => box.width > 0 || box.height > 0).sort((a, b) => {
|
|
35
|
+
const sameRow = Math.abs(a.y - b.y) < Math.min(a.height, b.height) / 2;
|
|
36
|
+
return sameRow ? a.x - b.x : a.y - b.y;
|
|
37
|
+
}).map(box => box.id);
|
|
38
|
+
}
|
|
39
|
+
class KeyboardChain {
|
|
40
|
+
entries = /* @__PURE__ */new Map();
|
|
41
|
+
order = [];
|
|
42
|
+
listeners = /* @__PURE__ */new Set();
|
|
43
|
+
pending = false;
|
|
44
|
+
subscribe = listener => {
|
|
45
|
+
this.listeners.add(listener);
|
|
46
|
+
return () => {
|
|
47
|
+
this.listeners.delete(listener);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
register(entry) {
|
|
51
|
+
this.entries.set(entry.id, entry);
|
|
52
|
+
this.invalidate();
|
|
53
|
+
return () => {
|
|
54
|
+
this.entries.delete(entry.id);
|
|
55
|
+
this.invalidate();
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** A field that has not been measured yet reads as last, so it never claims "next" falsely. */
|
|
59
|
+
isLast(id) {
|
|
60
|
+
const at = this.order.indexOf(id);
|
|
61
|
+
return at === -1 || at === this.order.length - 1;
|
|
62
|
+
}
|
|
63
|
+
invalidate() {
|
|
64
|
+
if (this.pending) return;
|
|
65
|
+
this.pending = true;
|
|
66
|
+
void Promise.resolve().then(async () => {
|
|
67
|
+
this.pending = false;
|
|
68
|
+
await this.refresh();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Focus the field after `id`, or run onLast from the last one. Uses the
|
|
73
|
+
* order measured at layout, and measures first only for a field it has not
|
|
74
|
+
* placed yet.
|
|
75
|
+
*/
|
|
76
|
+
advance(id, onLast) {
|
|
77
|
+
if (!this.order.includes(id)) {
|
|
78
|
+
void this.refresh().then(order => this.step(order, id, onLast));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.step(this.order, id, onLast);
|
|
82
|
+
}
|
|
83
|
+
step(order, id, onLast) {
|
|
84
|
+
const next = order[order.indexOf(id) + 1];
|
|
85
|
+
const entry = order.includes(id) && next ? this.entries.get(next) : void 0;
|
|
86
|
+
if (entry) entry.focus();else onLast();
|
|
87
|
+
}
|
|
88
|
+
async refresh() {
|
|
89
|
+
const boxes = await Promise.all([...this.entries.values()].map(entry => new Promise(resolve => entry.measure(resolve))));
|
|
90
|
+
const order = readingOrder(boxes.filter(box => Boolean(box)));
|
|
91
|
+
const changed = order.length !== this.order.length || order.some((id, i) => id !== this.order[i]);
|
|
92
|
+
this.order = order;
|
|
93
|
+
if (changed) for (const listener of this.listeners) listener();
|
|
94
|
+
return order;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const KeyboardChainContext = (0, import_react.createContext)(new KeyboardChain());
|
|
98
|
+
function KeyboardChainScope({
|
|
99
|
+
children
|
|
100
|
+
}) {
|
|
101
|
+
const [chain] = (0, import_react.useState)(() => new KeyboardChain());
|
|
102
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(KeyboardChainContext.Provider, {
|
|
103
|
+
value: chain,
|
|
104
|
+
children
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var chain_exports = {};
|
|
26
|
+
__export(chain_exports, {
|
|
27
|
+
KeyboardChain: () => KeyboardChain,
|
|
28
|
+
KeyboardChainContext: () => KeyboardChainContext,
|
|
29
|
+
KeyboardChainScope: () => KeyboardChainScope,
|
|
30
|
+
readingOrder: () => readingOrder
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(chain_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
function _class_call_check(instance, Constructor) {
|
|
36
|
+
if (!(instance instanceof Constructor)) {
|
|
37
|
+
throw new TypeError("Cannot call a class as a function");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function _defineProperties(target, props) {
|
|
41
|
+
for (var i = 0; i < props.length; i++) {
|
|
42
|
+
var descriptor = props[i];
|
|
43
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
44
|
+
descriptor.configurable = true;
|
|
45
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
46
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
50
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
51
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
52
|
+
return Constructor;
|
|
53
|
+
}
|
|
54
|
+
function _define_property(obj, key, value) {
|
|
55
|
+
if (key in obj) {
|
|
56
|
+
Object.defineProperty(obj, key, {
|
|
57
|
+
value,
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
obj[key] = value;
|
|
64
|
+
}
|
|
65
|
+
return obj;
|
|
66
|
+
}
|
|
67
|
+
function readingOrder(boxes) {
|
|
68
|
+
return boxes.filter(function (box) {
|
|
69
|
+
return box.width > 0 || box.height > 0;
|
|
70
|
+
}).sort(function (a, b) {
|
|
71
|
+
var sameRow = Math.abs(a.y - b.y) < Math.min(a.height, b.height) / 2;
|
|
72
|
+
return sameRow ? a.x - b.x : a.y - b.y;
|
|
73
|
+
}).map(function (box) {
|
|
74
|
+
return box.id;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
var KeyboardChain = /* @__PURE__ */function () {
|
|
78
|
+
"use strict";
|
|
79
|
+
|
|
80
|
+
function KeyboardChain2() {
|
|
81
|
+
var _this = this;
|
|
82
|
+
_class_call_check(this, KeyboardChain2);
|
|
83
|
+
_define_property(this, "entries", /* @__PURE__ */new Map());
|
|
84
|
+
_define_property(this, "order", []);
|
|
85
|
+
_define_property(this, "listeners", /* @__PURE__ */new Set());
|
|
86
|
+
_define_property(this, "pending", false);
|
|
87
|
+
_define_property(this, "subscribe", function (listener) {
|
|
88
|
+
_this.listeners.add(listener);
|
|
89
|
+
return function () {
|
|
90
|
+
_this.listeners.delete(listener);
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
_create_class(KeyboardChain2, [{
|
|
95
|
+
key: "register",
|
|
96
|
+
value: function register(entry) {
|
|
97
|
+
var _this = this;
|
|
98
|
+
this.entries.set(entry.id, entry);
|
|
99
|
+
this.invalidate();
|
|
100
|
+
return function () {
|
|
101
|
+
_this.entries.delete(entry.id);
|
|
102
|
+
_this.invalidate();
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
/** A field that has not been measured yet reads as last, so it never claims "next" falsely. */
|
|
107
|
+
key: "isLast",
|
|
108
|
+
value: function isLast(id) {
|
|
109
|
+
var at = this.order.indexOf(id);
|
|
110
|
+
return at === -1 || at === this.order.length - 1;
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "invalidate",
|
|
114
|
+
value: function invalidate() {
|
|
115
|
+
var _this = this;
|
|
116
|
+
if (this.pending) return;
|
|
117
|
+
this.pending = true;
|
|
118
|
+
void Promise.resolve().then(async function () {
|
|
119
|
+
_this.pending = false;
|
|
120
|
+
await _this.refresh();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
/**
|
|
125
|
+
* Focus the field after `id`, or run onLast from the last one. Uses the
|
|
126
|
+
* order measured at layout, and measures first only for a field it has not
|
|
127
|
+
* placed yet.
|
|
128
|
+
*/
|
|
129
|
+
key: "advance",
|
|
130
|
+
value: function advance(id, onLast) {
|
|
131
|
+
var _this = this;
|
|
132
|
+
if (!this.order.includes(id)) {
|
|
133
|
+
void this.refresh().then(function (order) {
|
|
134
|
+
return _this.step(order, id, onLast);
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.step(this.order, id, onLast);
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "step",
|
|
142
|
+
value: function step(order, id, onLast) {
|
|
143
|
+
var next = order[order.indexOf(id) + 1];
|
|
144
|
+
var entry = order.includes(id) && next ? this.entries.get(next) : void 0;
|
|
145
|
+
if (entry) entry.focus();else onLast();
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "refresh",
|
|
149
|
+
value: async function refresh() {
|
|
150
|
+
var _this = this;
|
|
151
|
+
var boxes = await Promise.all([...this.entries.values()].map(function (entry) {
|
|
152
|
+
return new Promise(function (resolve) {
|
|
153
|
+
return entry.measure(resolve);
|
|
154
|
+
});
|
|
155
|
+
}));
|
|
156
|
+
var order = readingOrder(boxes.filter(function (box) {
|
|
157
|
+
return Boolean(box);
|
|
158
|
+
}));
|
|
159
|
+
var changed = order.length !== this.order.length || order.some(function (id, i) {
|
|
160
|
+
return id !== _this.order[i];
|
|
161
|
+
});
|
|
162
|
+
this.order = order;
|
|
163
|
+
var _iteratorNormalCompletion = true,
|
|
164
|
+
_didIteratorError = false,
|
|
165
|
+
_iteratorError = void 0;
|
|
166
|
+
if (changed) try {
|
|
167
|
+
for (var _iterator = this.listeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
168
|
+
var listener = _step.value;
|
|
169
|
+
listener();
|
|
170
|
+
}
|
|
171
|
+
} catch (err) {
|
|
172
|
+
_didIteratorError = true;
|
|
173
|
+
_iteratorError = err;
|
|
174
|
+
} finally {
|
|
175
|
+
try {
|
|
176
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
177
|
+
_iterator.return();
|
|
178
|
+
}
|
|
179
|
+
} finally {
|
|
180
|
+
if (_didIteratorError) {
|
|
181
|
+
throw _iteratorError;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return order;
|
|
186
|
+
}
|
|
187
|
+
}]);
|
|
188
|
+
return KeyboardChain2;
|
|
189
|
+
}();
|
|
190
|
+
var KeyboardChainContext = /* @__PURE__ */(0, import_react.createContext)(new KeyboardChain());
|
|
191
|
+
function KeyboardChainScope(param) {
|
|
192
|
+
var {
|
|
193
|
+
children
|
|
194
|
+
} = param;
|
|
195
|
+
var [chain] = (0, import_react.useState)(function () {
|
|
196
|
+
return new KeyboardChain();
|
|
197
|
+
});
|
|
198
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(KeyboardChainContext.Provider, {
|
|
199
|
+
value: chain,
|
|
200
|
+
children
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=chain.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","chain_exports","__export","KeyboardChain","KeyboardChainContext","KeyboardChainScope","readingOrder","module","exports","import_jsx_runtime","require","import_react","_class_call_check","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","prototype","_define_property","obj","boxes","filter","box","width","height","sort","a","b","sameRow","Math","abs","y","min","x","map","id","KeyboardChain2","_this","Map","Set","listener","listeners","add","delete","register","entry","entries","set","invalidate"],"sources":["../../../src/keyboard/chain.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AASAC,MAAA,CAAAC,OAAA,GAAAZ,YAAwD,CAAAK,aAAA;AAwG/C,IAAAQ,kBAAA,GAAAC,OAAA;AAvFF,IAAAC,YAAS,GAAAD,OAAa,QAA6B;AACxD,SAAOE,iBACIA,CAAAC,QAAY,EAAAC,WAAa;EAEhC,MAAAD,QAAM,YAAeC,WAAa,GAAI;IACtC,UAAOC,SAAY,oCAAkB;EACvC;AAEJ;AAEO,SAAMC,iBAAcA,CAAAC,MAAA,EAAAC,KAAA;EACjB,SAAAC,CAAU,MAAAA,CAAA,GAAAD,KAAA,CAAAE,MAAI,EAAwBD,CAAA;IACtC,IAAAE,UAAmB,GAAAH,KAAA,CAAAC,CAAA;IACnBE,UAAY,CAAAC,UAAA,GAAAD,UAAoB,CAAAC,UAAA;IAChCD,UAAU,CAAAE,YAAA;IAElB,WAAa,IAAAF,UAAyB,EAAAA,UAAA,CAAAG,QAAA;IACpCC,MAAK,CAAAC,cAAc,CAAAT,MAAQ,EAAAI,UAAA,CAAAM,GAAA,EAAAN,UAAA;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AAU,qBAAAoB,GAAA;IAClCpB,gBAAA;IAEQA,gBAAkC,OAAoB,gCAAAqB,GAAA;IAC5DrB,gBAAa,KAAM,WAAM,EAAQ,KAAM,CAAC;IACxCA,gBAAc,KAAM,aAAW,EAAK,UAAOsB,QAAK;MAChDH,KAAI,CAAAI,SAAa,CAAAC,GAAA,CAAAF,QAAM;MAAA,OAClB,YAAO;QACdH,KAAA,CAAAI,SAAA,CAAAE,MAAA,CAAAH,QAAA;MAEA;IACE;EAA4B;EACC1B,aACxB,CAAAsB,cAAc,EAA+B,CAAkC;IAEpFvB,GAAA;IACA3B,KAAM,WAAQ0D,SAAaC,KAAA,EAAM;MACjC,IAAMR,KAAA,GACJ;MACF,IAAK,CAAAS,OAAQ,CAAAC,GAAA,CAAAF,KAAA,CAAAV,EAAA,EAAAU,KAAA;MACT,KAAAG,UAAS;MACb,OAAO;QACTX,KAAA,CAAAS,OAAA,CAAAH,MAAA,CAAAE,KAAA,CAAAV,EAAA;QACFE,KAAA,CAAAW,UAAA;MAEa;IAGN;EACL,GACA;IACF","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var keyboard_exports = {};
|
|
24
|
+
__export(keyboard_exports, {
|
|
25
|
+
KeyboardChain: () => import_chain.KeyboardChain,
|
|
26
|
+
KeyboardChainContext: () => import_chain.KeyboardChainContext,
|
|
27
|
+
KeyboardChainScope: () => import_chain.KeyboardChainScope,
|
|
28
|
+
KeyboardDoneBar: () => import_KeyboardDoneBar.KeyboardDoneBar,
|
|
29
|
+
readingOrder: () => import_chain.readingOrder,
|
|
30
|
+
useKeyboardChain: () => import_useKeyboardChain.useKeyboardChain
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(keyboard_exports);
|
|
33
|
+
var import_chain = require("./chain.cjs");
|
|
34
|
+
var import_KeyboardDoneBar = require("./KeyboardDoneBar.cjs");
|
|
35
|
+
var import_useKeyboardChain = require("./useKeyboardChain.cjs");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var keyboard_exports = {};
|
|
26
|
+
__export(keyboard_exports, {
|
|
27
|
+
KeyboardChain: () => import_chain.KeyboardChain,
|
|
28
|
+
KeyboardChainContext: () => import_chain.KeyboardChainContext,
|
|
29
|
+
KeyboardChainScope: () => import_chain.KeyboardChainScope,
|
|
30
|
+
KeyboardDoneBar: () => import_KeyboardDoneBar.KeyboardDoneBar,
|
|
31
|
+
readingOrder: () => import_chain.readingOrder,
|
|
32
|
+
useKeyboardChain: () => import_useKeyboardChain.useKeyboardChain
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(keyboard_exports);
|
|
35
|
+
var import_chain = require("./chain.native.js");
|
|
36
|
+
var import_KeyboardDoneBar = require("./KeyboardDoneBar.native.js");
|
|
37
|
+
var import_useKeyboardChain = require("./useKeyboardChain.native.js");
|
|
38
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","keyboard_exports","__export","KeyboardChain","import_chain","KeyboardChainContext","KeyboardChainScope","KeyboardDoneBar","import_KeyboardDoneBar","readingOrder","useKeyboardChain","import_useKeyboardChain","module","exports","require"],"sources":["../../../src/keyboard/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAC,YAAA,CAAAD,aAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAD,YAAA,CAAAC,oBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAF,YAAA,CAAAE,kBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAC,sBAAA,CAAAD,eAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAL,YAAA,CAAAK,YAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAC,uBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAjB,YAAsF,CAAAK,gBAAA;AAEtF,IAAAG,YAAA,GAAAU,OAAA,oBAAgC;AAChC,IAAAN,sBAAA,GAAAM,OAAiC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
}), mod);
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
}), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(types_exports);
|
|
21
|
+
//# sourceMappingURL=types.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../../src/keyboard/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var useKeyboardChain_exports = {};
|
|
24
|
+
__export(useKeyboardChain_exports, {
|
|
25
|
+
useKeyboardChain: () => useKeyboardChain
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useKeyboardChain_exports);
|
|
28
|
+
function useKeyboardChain(_options) {
|
|
29
|
+
return {
|
|
30
|
+
inputProps: {},
|
|
31
|
+
accessory: null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var useKeyboardChain_native_exports = {};
|
|
26
|
+
__export(useKeyboardChain_native_exports, {
|
|
27
|
+
useKeyboardChain: () => useKeyboardChain
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useKeyboardChain_native_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_react_native = require("react-native");
|
|
33
|
+
var import_chain = require("./chain.native.js");
|
|
34
|
+
var import_KeyboardDoneBar = require("./KeyboardDoneBar.native.js");
|
|
35
|
+
function useKeyboardChain(param) {
|
|
36
|
+
var {
|
|
37
|
+
inputRef,
|
|
38
|
+
enabled = true,
|
|
39
|
+
multiline,
|
|
40
|
+
onSubmitLast,
|
|
41
|
+
onSubmitEditing
|
|
42
|
+
} = param;
|
|
43
|
+
var chain = (0, import_react.useContext)(import_chain.KeyboardChainContext);
|
|
44
|
+
var id = (0, import_react.useId)();
|
|
45
|
+
var accessoryId = `mpo-keyboard-done${id}`;
|
|
46
|
+
var chained = enabled && !multiline;
|
|
47
|
+
var entry = (0, import_react.useMemo)(function () {
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
focus: function focus() {
|
|
51
|
+
var _inputRef_current_focus, _inputRef_current;
|
|
52
|
+
return (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : (_inputRef_current_focus = _inputRef_current.focus) === null || _inputRef_current_focus === void 0 ? void 0 : _inputRef_current_focus.call(_inputRef_current);
|
|
53
|
+
},
|
|
54
|
+
measure: function measure(done) {
|
|
55
|
+
var input = inputRef.current;
|
|
56
|
+
if (!(input === null || input === void 0 ? void 0 : input.measureInWindow)) return done(void 0);
|
|
57
|
+
input.measureInWindow(function (x, y, width, height) {
|
|
58
|
+
return done({
|
|
59
|
+
id,
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
width,
|
|
63
|
+
height
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, [id, inputRef]);
|
|
69
|
+
(0, import_react.useEffect)(function () {
|
|
70
|
+
return chained ? chain.register(entry) : void 0;
|
|
71
|
+
}, [chain, chained, entry]);
|
|
72
|
+
var isLast = (0, import_react.useSyncExternalStore)(chain.subscribe, function () {
|
|
73
|
+
return chain.isLast(id);
|
|
74
|
+
}, function () {
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
var handleSubmitEditing = (0, import_react.useCallback)(function () {
|
|
78
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
79
|
+
args[_key] = arguments[_key];
|
|
80
|
+
}
|
|
81
|
+
onSubmitEditing === null || onSubmitEditing === void 0 ? void 0 : onSubmitEditing(...args);
|
|
82
|
+
chain.advance(id, function () {
|
|
83
|
+
import_react_native.Keyboard.dismiss();
|
|
84
|
+
onSubmitLast === null || onSubmitLast === void 0 ? void 0 : onSubmitLast();
|
|
85
|
+
});
|
|
86
|
+
}, [chain, id, onSubmitEditing, onSubmitLast]);
|
|
87
|
+
var relayout = (0, import_react.useCallback)(function () {
|
|
88
|
+
return chain.invalidate();
|
|
89
|
+
}, [chain]);
|
|
90
|
+
if (!enabled) return {
|
|
91
|
+
inputProps: {},
|
|
92
|
+
accessory: null
|
|
93
|
+
};
|
|
94
|
+
var ios = import_react_native.Platform.OS === "ios";
|
|
95
|
+
return {
|
|
96
|
+
inputProps: {
|
|
97
|
+
...(ios ? {
|
|
98
|
+
inputAccessoryViewID: accessoryId
|
|
99
|
+
} : void 0),
|
|
100
|
+
...(chained ? {
|
|
101
|
+
returnKeyType: isLast ? "done" : "next",
|
|
102
|
+
// "submit" keeps the keyboard up while focus moves on, so it does
|
|
103
|
+
// not drop and rise again between fields.
|
|
104
|
+
submitBehavior: isLast ? "blurAndSubmit" : "submit",
|
|
105
|
+
onSubmitEditing: handleSubmitEditing,
|
|
106
|
+
onLayout: relayout
|
|
107
|
+
} : void 0)
|
|
108
|
+
},
|
|
109
|
+
accessory: ios ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_KeyboardDoneBar.KeyboardDoneBar, {
|
|
110
|
+
nativeID: accessoryId
|
|
111
|
+
}) : null
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=useKeyboardChain.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useKeyboardChain_native_exports","__export","useKeyboardChain","module","exports","__toCommonJS","import_jsx_runtime","require","import_react","import_react_native","import_chain","import_KeyboardDoneBar","param","inputRef","enabled","multiline","onSubmitLast","onSubmitEditing","chain","useContext","KeyboardChainContext","id","useId","accessoryId","chained","entry","useMemo","focus","_inputRef_current_focus","_inputRef_current","current","call","measure","done","input","measureInWindow","x","y","width","height","useEffect","register","isLast","useSyncExternalStore","subscribe","handleSubmitEditing","useCallback","_len","arguments","length","args","Array","_key","advance","Keyboard","dismiss","relayout","invalidate","inputProps","accessory","ios","Platform","OS","inputAccessoryViewID","returnKeyType","submitBehavior","onLayout","jsx","KeyboardDoneBar","nativeID"],"sources":["../../../src/keyboard/useKeyboardChain.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,+BAAA;AAAAC,QAAA,CAAAD,+BAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,+BAAA;AAAA,IAAAM,kBAAA,GAA4BC,OAAA;AAC5B,IAAAC,YAAA,GAAyFD,OAAA;AACzF,IAAAE,mBAAA,GAAmCF,OAAA;AACnC,IAAAG,YAAA,GAAqCH,OAAA;AACrC,IAAAI,sBAAA,GAAgCJ,OAAA;AACzB,SAASL,iBAAiBU,KAAA,EAAO;EACpC,IAAI;IAAEC,QAAA;IAAUC,OAAA,GAAU;IAAMC,SAAA;IAAWC,YAAA;IAAcC;EAAgB,IAAIL,KAAA;EAC7E,IAAIM,KAAA,OAAQV,YAAA,CAAAW,UAAA,EAAWT,YAAA,CAAAU,oBAAo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QACjBqB,QAAA,EAAUV;MACd,IAAI;IACR;IACAG,SAAA,EAAWC,GAAA,GAAoB,mBAAAtD,kBAAA,CAAA6D,GAAA,EAAKxD,sBAAA,CAAAyD,eAAA,EAAiB;MACjDC,QAAA,EAAU9C;IACd,CAAC,IAAI;EACT;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var nativeAutoFocus_exports = {};
|
|
24
|
+
__export(nativeAutoFocus_exports, {
|
|
25
|
+
nativeAutoFocus: () => nativeAutoFocus
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(nativeAutoFocus_exports);
|
|
28
|
+
var import_tamagui = require("tamagui");
|
|
29
|
+
function nativeAutoFocus({
|
|
30
|
+
autoFocus,
|
|
31
|
+
autoFocusNative
|
|
32
|
+
}) {
|
|
33
|
+
if (import_tamagui.isWeb || autoFocusNative !== void 0 || autoFocus === void 0) return void 0;
|
|
34
|
+
return {
|
|
35
|
+
autoFocusNative: autoFocus
|
|
36
|
+
};
|
|
37
|
+
}
|