react-native-unified-action-sheet 0.2.0 → 0.4.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/CHANGELOG.md +87 -1
- package/README.md +44 -112
- package/android/build.gradle +28 -1
- package/android/src/main/java/com/unifiedactionsheet/ActionSheetOptions.kt +41 -2
- package/android/src/main/java/com/unifiedactionsheet/PromptOptions.kt +27 -5
- package/android/src/main/java/com/unifiedactionsheet/SheetContentBuilder.kt +75 -9
- package/android/src/main/java/com/unifiedactionsheet/SheetPresenters.kt +61 -10
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetModule.kt +14 -7
- package/android/src/material/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/android/src/material/java/com/unifiedactionsheet/MaterialBottomSheetPresenter.kt +153 -0
- package/android/src/material/res/values/unified_action_sheet_bottom_sheet.xml +22 -0
- package/android/src/noMaterial/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/app.plugin.js +1 -0
- package/ios/BottomSheetViewController.swift +210 -0
- package/ios/UnifiedActionSheet.mm +51 -5
- package/ios/UnifiedActionSheetImpl.swift +259 -22
- package/jest/index.d.ts +12 -9
- package/jest/index.js +37 -18
- package/lib/commonjs/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/commonjs/index.js +102 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/module/index.js +102 -18
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts +10 -1
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts +5 -2
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/common-options.interface.d.ts +9 -0
- package/lib/typescript/commonjs/src/common-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +6 -6
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts +10 -6
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts +10 -1
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts +5 -2
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/common-options.interface.d.ts +9 -0
- package/lib/typescript/module/src/common-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +6 -6
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/prompt-options.interface.d.ts +10 -6
- package/lib/typescript/module/src/prompt-options.interface.d.ts.map +1 -1
- package/package.json +12 -2
- package/plugin/withUnifiedActionSheet.js +58 -0
- package/src/NativeUnifiedActionSheet.ts +12 -2
- package/src/action-sheet-options.interface.ts +12 -1
- package/src/common-options.interface.ts +18 -0
- package/src/index.tsx +147 -42
- package/src/prompt-options.interface.ts +21 -5
package/lib/commonjs/index.js
CHANGED
|
@@ -31,6 +31,7 @@ const toWireButtons = buttons => {
|
|
|
31
31
|
const destructive = [];
|
|
32
32
|
const disabled = [];
|
|
33
33
|
let cancelButtonIndex;
|
|
34
|
+
let preferredButtonIndex;
|
|
34
35
|
buttons.forEach((button, index) => {
|
|
35
36
|
labels.push(button.label);
|
|
36
37
|
if (button.style === 'destructive') destructive.push(index);
|
|
@@ -38,6 +39,9 @@ const toWireButtons = buttons => {
|
|
|
38
39
|
cancelButtonIndex = index;
|
|
39
40
|
}
|
|
40
41
|
if (button.disabled) disabled.push(index);
|
|
42
|
+
if (button.preferred && preferredButtonIndex == null) {
|
|
43
|
+
preferredButtonIndex = index;
|
|
44
|
+
}
|
|
41
45
|
});
|
|
42
46
|
return {
|
|
43
47
|
options: labels,
|
|
@@ -49,12 +53,52 @@ const toWireButtons = buttons => {
|
|
|
49
53
|
}),
|
|
50
54
|
...(disabled.length === 0 ? {} : {
|
|
51
55
|
disabledButtonIndices: disabled
|
|
56
|
+
}),
|
|
57
|
+
...(preferredButtonIndex == null ? {} : {
|
|
58
|
+
preferredButtonIndex
|
|
52
59
|
})
|
|
53
60
|
};
|
|
54
61
|
};
|
|
62
|
+
|
|
63
|
+
/// Native sides only report an index: DISMISSED_BY_API, the cancel button's
|
|
64
|
+
/// index, -1 (a cancel gesture with no cancel button), or another button.
|
|
65
|
+
const toCloseResult = (buttonIndex, cancelButtonIndex) => {
|
|
66
|
+
if (buttonIndex === DISMISSED_BY_API) {
|
|
67
|
+
return {
|
|
68
|
+
reason: 'dismissed',
|
|
69
|
+
buttonIndex: undefined
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (buttonIndex < 0 || buttonIndex === cancelButtonIndex) {
|
|
73
|
+
return {
|
|
74
|
+
reason: 'cancelled',
|
|
75
|
+
buttonIndex
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
reason: 'selected',
|
|
80
|
+
buttonIndex
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const DISMISSED = {
|
|
84
|
+
reason: 'dismissed',
|
|
85
|
+
buttonIndex: undefined
|
|
86
|
+
};
|
|
55
87
|
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
56
|
-
// A
|
|
57
|
-
.
|
|
88
|
+
// A native failure reads as a cancellation rather than a rejection.
|
|
89
|
+
.catch(() => options.cancelButtonIndex ?? -1).then(buttonIndex => toCloseResult(buttonIndex, options.cancelButtonIndex));
|
|
90
|
+
let warnedMaterialDisabled = false;
|
|
91
|
+
|
|
92
|
+
/// 'bottom' needs Material on Android, which the app opts into at build time.
|
|
93
|
+
/// Without it the sheet falls back to a centered dialog; say so once, in
|
|
94
|
+
/// development, since the fallback alone looks like the option was ignored.
|
|
95
|
+
const warnIfBottomUnavailable = presentationStyle => {
|
|
96
|
+
if (!__DEV__ || warnedMaterialDisabled || _reactNative.Platform.OS !== 'android' || presentationStyle !== 'bottom' || nativeModule().getConstants().isMaterialEnabled) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
warnedMaterialDisabled = true;
|
|
100
|
+
console.warn("react-native-unified-action-sheet: presentationStyle 'bottom' needs Material on Android, " + 'so this sheet falls back to a centered dialog. Set unifiedActionSheet.material=true in ' + "android/gradle.properties, or add ['react-native-unified-action-sheet', { material: true }] " + 'to your Expo plugins, then rebuild the app.');
|
|
101
|
+
};
|
|
58
102
|
|
|
59
103
|
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
60
104
|
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
@@ -80,15 +124,22 @@ const withAnchorRect = (wire, anchor) => {
|
|
|
80
124
|
const showActionSheetWithOptions = options => {
|
|
81
125
|
const wire = toWireOptions(options);
|
|
82
126
|
|
|
83
|
-
// -1 and
|
|
84
|
-
const press =
|
|
85
|
-
if (buttonIndex != null)
|
|
86
|
-
|
|
127
|
+
// -1 and a dismissal index nothing, so optional chaining covers both.
|
|
128
|
+
const press = result => {
|
|
129
|
+
if (result.buttonIndex != null) {
|
|
130
|
+
options.options[result.buttonIndex]?.onPress?.();
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
87
133
|
};
|
|
88
134
|
if (_reactNative.Platform.OS !== 'ios' && _reactNative.Platform.OS !== 'android') {
|
|
89
|
-
return Promise.resolve(
|
|
135
|
+
return Promise.resolve(DISMISSED);
|
|
90
136
|
}
|
|
91
|
-
|
|
137
|
+
warnIfBottomUnavailable(options.presentationStyle);
|
|
138
|
+
|
|
139
|
+
// A bottom sheet has no anchor, so don't measure one: on iPad a rect would
|
|
140
|
+
// turn the sheet into an arrowed popover pointing at it.
|
|
141
|
+
const anchor = options.presentationStyle === 'bottom' ? undefined : options.anchor;
|
|
142
|
+
return withAnchorRect(wire, anchor).then(showWithNativeModule).then(press);
|
|
92
143
|
};
|
|
93
144
|
exports.showActionSheetWithOptions = showActionSheetWithOptions;
|
|
94
145
|
const dismissActionSheet = () => {
|
|
@@ -97,8 +148,8 @@ const dismissActionSheet = () => {
|
|
|
97
148
|
}
|
|
98
149
|
};
|
|
99
150
|
|
|
100
|
-
/// Closes every open sheet, not just the top-most one. Each resolves
|
|
101
|
-
///
|
|
151
|
+
/// Closes every open sheet, not just the top-most one. Each resolves as
|
|
152
|
+
/// 'dismissed', exactly as with dismissActionSheet().
|
|
102
153
|
exports.dismissActionSheet = dismissActionSheet;
|
|
103
154
|
const dismissAllActionSheets = () => {
|
|
104
155
|
if (_reactNative.Platform.OS === 'ios' || _reactNative.Platform.OS === 'android') {
|
|
@@ -114,24 +165,57 @@ exports.dismissAllActionSheets = dismissAllActionSheets;
|
|
|
114
165
|
const showPromptWithOptions = options => {
|
|
115
166
|
const {
|
|
116
167
|
options: buttons,
|
|
168
|
+
secureTextEntry,
|
|
169
|
+
type,
|
|
117
170
|
...rest
|
|
118
171
|
} = options;
|
|
172
|
+
const textRequired = buttons.flatMap((button, index) => button.requiresText ? [index] : []);
|
|
119
173
|
const wire = {
|
|
120
174
|
...rest,
|
|
121
|
-
...toWireButtons(buttons)
|
|
175
|
+
...toWireButtons(buttons),
|
|
176
|
+
// One field of truth for the native sides: the old boolean maps onto type.
|
|
177
|
+
type: type ?? (secureTextEntry ? 'secure-text' : 'plain-text'),
|
|
178
|
+
...(textRequired.length === 0 ? {} : {
|
|
179
|
+
textRequiredButtonIndices: textRequired
|
|
180
|
+
})
|
|
122
181
|
};
|
|
182
|
+
const hasPassword = wire.type === 'login-password';
|
|
123
183
|
if (_reactNative.Platform.OS !== 'ios' && _reactNative.Platform.OS !== 'android') {
|
|
124
|
-
return Promise.resolve(
|
|
184
|
+
return Promise.resolve({
|
|
185
|
+
...DISMISSED,
|
|
186
|
+
text: ''
|
|
187
|
+
});
|
|
125
188
|
}
|
|
126
|
-
return nativeModule().showPromptWithOptions(wire).
|
|
127
|
-
// A programmatic dismiss resolves with no selection, matching the sheet.
|
|
128
|
-
result.buttonIndex === DISMISSED_BY_API ? undefined : result).catch(() => ({
|
|
189
|
+
return nativeModule().showPromptWithOptions(wire).catch(() => ({
|
|
129
190
|
buttonIndex: wire.cancelButtonIndex ?? -1,
|
|
130
|
-
text: ''
|
|
191
|
+
text: '',
|
|
192
|
+
password: ''
|
|
193
|
+
})).then(({
|
|
194
|
+
buttonIndex,
|
|
195
|
+
text,
|
|
196
|
+
password
|
|
197
|
+
}) => ({
|
|
198
|
+
...toCloseResult(buttonIndex, wire.cancelButtonIndex),
|
|
199
|
+
text,
|
|
200
|
+
// Even a dismissal carries the fields, so a draft is recoverable.
|
|
201
|
+
...(hasPassword ? {
|
|
202
|
+
password
|
|
203
|
+
} : {})
|
|
131
204
|
})).then(result => {
|
|
132
|
-
// The
|
|
205
|
+
// The values go to the handler, so a caller using onPress alone never
|
|
133
206
|
// has to read the resolved value.
|
|
134
|
-
if (result
|
|
207
|
+
if (result.buttonIndex != null) {
|
|
208
|
+
const {
|
|
209
|
+
text,
|
|
210
|
+
password
|
|
211
|
+
} = result;
|
|
212
|
+
buttons[result.buttonIndex]?.onPress?.(hasPassword ? {
|
|
213
|
+
text,
|
|
214
|
+
password
|
|
215
|
+
} : {
|
|
216
|
+
text
|
|
217
|
+
});
|
|
218
|
+
}
|
|
135
219
|
return result;
|
|
136
220
|
});
|
|
137
221
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","preferredButtonIndex","forEach","button","index","push","label","style","preferred","length","destructiveButtonIndices","disabledButtonIndices","toCloseResult","buttonIndex","reason","undefined","DISMISSED","showWithNativeModule","showActionSheetWithOptions","catch","then","warnedMaterialDisabled","warnIfBottomUnavailable","presentationStyle","__DEV__","Platform","OS","getConstants","isMaterialEnabled","console","warn","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","result","onPress","exports","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","secureTextEntry","type","textRequired","flatMap","requiresText","textRequiredButtonIndices","hasPassword","text","password"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AA4CA,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AAcA,MAAMC,YAAY,GAAGA,CAAA,KACnBF,OAAO,CAAC,4BAA4B,CAAC,CAACG,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AAWF;AACA;AACA,MAAMI,aAAa,GACjBC,OAA2C,IAC3B;EAChB,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EACzC,IAAIC,oBAAwC;EAE5CL,OAAO,CAACM,OAAO,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;IACjCP,MAAM,CAACQ,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;IAEzB,IAAIH,MAAM,CAACI,KAAK,KAAK,aAAa,EAAET,WAAW,CAACO,IAAI,CAACD,KAAK,CAAC;IAC3D,IAAID,MAAM,CAACI,KAAK,KAAK,QAAQ,IA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AAC,CACFvC,IAAI,CAAC,CAAC;IAAEP,WAAW;IAAE6C,IAAI;IAAEC;EAAS,CAAC,MAA6B;IACjE,GAAG/C,aAAa,CAACC,WAAW,EAAEmB,IAAI,CAAChC,iBAAiB,CAAC;IACrD0D,IAAI;IACJ;IACA,IAAID,WAAW,GAAG;MAAEE;IAAS,CAAC,GAAG,CAAC,CAAC;EACrC,CAAC,CAAC,CAAC,CACFvC,IAAI,CAAEyB,MAAM,IAAK;IAChB;IACA;IACA,IAAIA,MAAM,CAAChC,WAAW,IAAI,IAAI,EAAE;MAC9B,MAAM;QAAE6C,IAAI;QAAEC;MAAS,CAAC,GAAGd,MAAM;MACjCjD,OAAO,CAACiD,MAAM,CAAChC,WAAW,CAAC,EAAEiC,OAAO,GAClCW,WAAW,GAAG;QAAEC,IAAI;QAAEC;MAAS,CAAC,GAAG;QAAED;MAAK,CAC5C,CAAC;IACH;IAEA,OAAOb,MAAM;EACf,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAG,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AAuDpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const toWireButtons = buttons => {
|
|
|
27
27
|
const destructive = [];
|
|
28
28
|
const disabled = [];
|
|
29
29
|
let cancelButtonIndex;
|
|
30
|
+
let preferredButtonIndex;
|
|
30
31
|
buttons.forEach((button, index) => {
|
|
31
32
|
labels.push(button.label);
|
|
32
33
|
if (button.style === 'destructive') destructive.push(index);
|
|
@@ -34,6 +35,9 @@ const toWireButtons = buttons => {
|
|
|
34
35
|
cancelButtonIndex = index;
|
|
35
36
|
}
|
|
36
37
|
if (button.disabled) disabled.push(index);
|
|
38
|
+
if (button.preferred && preferredButtonIndex == null) {
|
|
39
|
+
preferredButtonIndex = index;
|
|
40
|
+
}
|
|
37
41
|
});
|
|
38
42
|
return {
|
|
39
43
|
options: labels,
|
|
@@ -45,12 +49,52 @@ const toWireButtons = buttons => {
|
|
|
45
49
|
}),
|
|
46
50
|
...(disabled.length === 0 ? {} : {
|
|
47
51
|
disabledButtonIndices: disabled
|
|
52
|
+
}),
|
|
53
|
+
...(preferredButtonIndex == null ? {} : {
|
|
54
|
+
preferredButtonIndex
|
|
48
55
|
})
|
|
49
56
|
};
|
|
50
57
|
};
|
|
58
|
+
|
|
59
|
+
/// Native sides only report an index: DISMISSED_BY_API, the cancel button's
|
|
60
|
+
/// index, -1 (a cancel gesture with no cancel button), or another button.
|
|
61
|
+
const toCloseResult = (buttonIndex, cancelButtonIndex) => {
|
|
62
|
+
if (buttonIndex === DISMISSED_BY_API) {
|
|
63
|
+
return {
|
|
64
|
+
reason: 'dismissed',
|
|
65
|
+
buttonIndex: undefined
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (buttonIndex < 0 || buttonIndex === cancelButtonIndex) {
|
|
69
|
+
return {
|
|
70
|
+
reason: 'cancelled',
|
|
71
|
+
buttonIndex
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
reason: 'selected',
|
|
76
|
+
buttonIndex
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const DISMISSED = {
|
|
80
|
+
reason: 'dismissed',
|
|
81
|
+
buttonIndex: undefined
|
|
82
|
+
};
|
|
51
83
|
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
52
|
-
// A
|
|
53
|
-
.
|
|
84
|
+
// A native failure reads as a cancellation rather than a rejection.
|
|
85
|
+
.catch(() => options.cancelButtonIndex ?? -1).then(buttonIndex => toCloseResult(buttonIndex, options.cancelButtonIndex));
|
|
86
|
+
let warnedMaterialDisabled = false;
|
|
87
|
+
|
|
88
|
+
/// 'bottom' needs Material on Android, which the app opts into at build time.
|
|
89
|
+
/// Without it the sheet falls back to a centered dialog; say so once, in
|
|
90
|
+
/// development, since the fallback alone looks like the option was ignored.
|
|
91
|
+
const warnIfBottomUnavailable = presentationStyle => {
|
|
92
|
+
if (!__DEV__ || warnedMaterialDisabled || Platform.OS !== 'android' || presentationStyle !== 'bottom' || nativeModule().getConstants().isMaterialEnabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
warnedMaterialDisabled = true;
|
|
96
|
+
console.warn("react-native-unified-action-sheet: presentationStyle 'bottom' needs Material on Android, " + 'so this sheet falls back to a centered dialog. Set unifiedActionSheet.material=true in ' + "android/gradle.properties, or add ['react-native-unified-action-sheet', { material: true }] " + 'to your Expo plugins, then rebuild the app.');
|
|
97
|
+
};
|
|
54
98
|
|
|
55
99
|
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
56
100
|
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
@@ -76,15 +120,22 @@ const withAnchorRect = (wire, anchor) => {
|
|
|
76
120
|
export const showActionSheetWithOptions = options => {
|
|
77
121
|
const wire = toWireOptions(options);
|
|
78
122
|
|
|
79
|
-
// -1 and
|
|
80
|
-
const press =
|
|
81
|
-
if (buttonIndex != null)
|
|
82
|
-
|
|
123
|
+
// -1 and a dismissal index nothing, so optional chaining covers both.
|
|
124
|
+
const press = result => {
|
|
125
|
+
if (result.buttonIndex != null) {
|
|
126
|
+
options.options[result.buttonIndex]?.onPress?.();
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
83
129
|
};
|
|
84
130
|
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
85
|
-
return Promise.resolve(
|
|
131
|
+
return Promise.resolve(DISMISSED);
|
|
86
132
|
}
|
|
87
|
-
|
|
133
|
+
warnIfBottomUnavailable(options.presentationStyle);
|
|
134
|
+
|
|
135
|
+
// A bottom sheet has no anchor, so don't measure one: on iPad a rect would
|
|
136
|
+
// turn the sheet into an arrowed popover pointing at it.
|
|
137
|
+
const anchor = options.presentationStyle === 'bottom' ? undefined : options.anchor;
|
|
138
|
+
return withAnchorRect(wire, anchor).then(showWithNativeModule).then(press);
|
|
88
139
|
};
|
|
89
140
|
export const dismissActionSheet = () => {
|
|
90
141
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
@@ -92,8 +143,8 @@ export const dismissActionSheet = () => {
|
|
|
92
143
|
}
|
|
93
144
|
};
|
|
94
145
|
|
|
95
|
-
/// Closes every open sheet, not just the top-most one. Each resolves
|
|
96
|
-
///
|
|
146
|
+
/// Closes every open sheet, not just the top-most one. Each resolves as
|
|
147
|
+
/// 'dismissed', exactly as with dismissActionSheet().
|
|
97
148
|
export const dismissAllActionSheets = () => {
|
|
98
149
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
99
150
|
nativeModule().dismissAllActionSheets();
|
|
@@ -107,24 +158,57 @@ export const dismissAllActionSheets = () => {
|
|
|
107
158
|
export const showPromptWithOptions = options => {
|
|
108
159
|
const {
|
|
109
160
|
options: buttons,
|
|
161
|
+
secureTextEntry,
|
|
162
|
+
type,
|
|
110
163
|
...rest
|
|
111
164
|
} = options;
|
|
165
|
+
const textRequired = buttons.flatMap((button, index) => button.requiresText ? [index] : []);
|
|
112
166
|
const wire = {
|
|
113
167
|
...rest,
|
|
114
|
-
...toWireButtons(buttons)
|
|
168
|
+
...toWireButtons(buttons),
|
|
169
|
+
// One field of truth for the native sides: the old boolean maps onto type.
|
|
170
|
+
type: type ?? (secureTextEntry ? 'secure-text' : 'plain-text'),
|
|
171
|
+
...(textRequired.length === 0 ? {} : {
|
|
172
|
+
textRequiredButtonIndices: textRequired
|
|
173
|
+
})
|
|
115
174
|
};
|
|
175
|
+
const hasPassword = wire.type === 'login-password';
|
|
116
176
|
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
117
|
-
return Promise.resolve(
|
|
177
|
+
return Promise.resolve({
|
|
178
|
+
...DISMISSED,
|
|
179
|
+
text: ''
|
|
180
|
+
});
|
|
118
181
|
}
|
|
119
|
-
return nativeModule().showPromptWithOptions(wire).
|
|
120
|
-
// A programmatic dismiss resolves with no selection, matching the sheet.
|
|
121
|
-
result.buttonIndex === DISMISSED_BY_API ? undefined : result).catch(() => ({
|
|
182
|
+
return nativeModule().showPromptWithOptions(wire).catch(() => ({
|
|
122
183
|
buttonIndex: wire.cancelButtonIndex ?? -1,
|
|
123
|
-
text: ''
|
|
184
|
+
text: '',
|
|
185
|
+
password: ''
|
|
186
|
+
})).then(({
|
|
187
|
+
buttonIndex,
|
|
188
|
+
text,
|
|
189
|
+
password
|
|
190
|
+
}) => ({
|
|
191
|
+
...toCloseResult(buttonIndex, wire.cancelButtonIndex),
|
|
192
|
+
text,
|
|
193
|
+
// Even a dismissal carries the fields, so a draft is recoverable.
|
|
194
|
+
...(hasPassword ? {
|
|
195
|
+
password
|
|
196
|
+
} : {})
|
|
124
197
|
})).then(result => {
|
|
125
|
-
// The
|
|
198
|
+
// The values go to the handler, so a caller using onPress alone never
|
|
126
199
|
// has to read the resolved value.
|
|
127
|
-
if (result
|
|
200
|
+
if (result.buttonIndex != null) {
|
|
201
|
+
const {
|
|
202
|
+
text,
|
|
203
|
+
password
|
|
204
|
+
} = result;
|
|
205
|
+
buttons[result.buttonIndex]?.onPress?.(hasPassword ? {
|
|
206
|
+
text,
|
|
207
|
+
password
|
|
208
|
+
} : {
|
|
209
|
+
text
|
|
210
|
+
});
|
|
211
|
+
}
|
|
128
212
|
return result;
|
|
129
213
|
});
|
|
130
214
|
};
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","
|
|
1
|
+
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","preferredButtonIndex","forEach","button","index","push","label","style","preferred","length","destructiveButtonIndices","disabledButtonIndices","toCloseResult","buttonIndex","reason","undefined","DISMISSED","showWithNativeModule","showActionSheetWithOptions","catch","then","warnedMaterialDisabled","warnIfBottomUnavailable","presentationStyle","__DEV__","OS","getConstants","isMaterialEnabled","console","warn","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","result","onPress","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","secureTextEntry","type","textRequired","flatMap","requiresText","textRequiredButtonIndices","hasPassword","text","password"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AA4CvC,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AAcA,MAAMC,YAAY,GAAGA,CAAA,KACnBC,OAAO,CAAC,4BAA4B,CAAC,CAACC,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AAWF;AACA;AACA,MAAMI,aAAa,GACjBC,OAA2C,IAC3B;EAChB,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EACzC,IAAIC,oBAAwC;EAE5CL,OAAO,CAACM,OAAO,CAAC,CAACC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ACZN,WAAW,EAAEkB,IAAI,CAAC/B,iBAAiB,IAAI,CAAC,CAAC;IACzCwD,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE;EACZ,CAAC,CAAC,CAAC,CACFrC,IAAI,CAAC,CAAC;IAAEP,WAAW;IAAE2C,IAAI;IAAEC;EAAS,CAAC,MAA6B;IACjE,GAAG7C,aAAa,CAACC,WAAW,EAAEkB,IAAI,CAAC/B,iBAAiB,CAAC;IACrDwD,IAAI;IACJ;IACA,IAAID,WAAW,GAAG;MAAEE;IAAS,CAAC,GAAG,CAAC,CAAC;EACrC,CAAC,CAAC,CAAC,CACFrC,IAAI,CAAEwB,MAAM,IAAK;IAChB;IACA;IACA,IAAIA,MAAM,CAAC/B,WAAW,IAAI,IAAI,EAAE;MAC9B,MAAM;QAAE2C,IAAI;QAAEC;MAAS,CAAC,GAAGb,MAAM;MACjChD,OAAO,CAACgD,MAAM,CAAC/B,WAAW,CAAC,EAAEgC,OAAO,GAClCU,WAAW,GAAG;QAAEC,IAAI;QAAEC;MAAS,CAAC,GAAG;QAAED;MAAK,CAC5C,CAAC;IACH;IAEA,OAAOZ,MAAM;EACf,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type TurboModule } from 'react-native';
|
|
2
2
|
export interface Spec extends TurboModule {
|
|
3
|
+
getConstants(): {
|
|
4
|
+
isMaterialEnabled: boolean;
|
|
5
|
+
};
|
|
3
6
|
showActionSheetWithOptions(options: {
|
|
4
7
|
options: string[];
|
|
5
8
|
cancelButtonIndex?: number;
|
|
@@ -14,6 +17,8 @@ export interface Spec extends TurboModule {
|
|
|
14
17
|
userInterfaceStyle?: string;
|
|
15
18
|
presentationStyle?: string;
|
|
16
19
|
anchorAlignment?: string;
|
|
20
|
+
preferredButtonIndex?: number;
|
|
21
|
+
detents?: string[];
|
|
17
22
|
anchorRect?: {
|
|
18
23
|
x: number;
|
|
19
24
|
y: number;
|
|
@@ -28,10 +33,13 @@ export interface Spec extends TurboModule {
|
|
|
28
33
|
disabledButtonIndices?: number[];
|
|
29
34
|
title?: string;
|
|
30
35
|
message?: string;
|
|
36
|
+
preferredButtonIndex?: number;
|
|
37
|
+
textRequiredButtonIndices?: number[];
|
|
38
|
+
type?: string;
|
|
31
39
|
placeholder?: string;
|
|
40
|
+
passwordPlaceholder?: string;
|
|
32
41
|
defaultValue?: string;
|
|
33
42
|
keyboardType?: string;
|
|
34
|
-
secureTextEntry?: boolean;
|
|
35
43
|
tintColor?: string;
|
|
36
44
|
cancelButtonTintColor?: string;
|
|
37
45
|
destructiveColor?: string;
|
|
@@ -40,6 +48,7 @@ export interface Spec extends TurboModule {
|
|
|
40
48
|
}): Promise<{
|
|
41
49
|
buttonIndex: number;
|
|
42
50
|
text: string;
|
|
51
|
+
password: string;
|
|
43
52
|
}>;
|
|
44
53
|
dismissActionSheet(): void;
|
|
45
54
|
dismissAllActionSheets(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeUnifiedActionSheet.d.ts","sourceRoot":"","sources":["../../../../src/NativeUnifiedActionSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,0BAA0B,CAAC,OAAO,EAAE;QAClC,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC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,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,kBAAkB,IAAI,IAAI,CAAC;IAC3B,sBAAsB,IAAI,IAAI,CAAC;CAChC;;AAED,wBAA4E"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface';
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface, CloseResultInterface } from './common-options.interface';
|
|
2
2
|
export interface ActionSheetButtonInterface extends BaseButtonInterface {
|
|
3
3
|
onPress?: () => void;
|
|
4
4
|
}
|
|
5
5
|
export interface ActionSheetAnchorInterface {
|
|
6
6
|
measureInWindow: (callback: (x: number, y: number, width: number, height: number) => void) => void;
|
|
7
7
|
}
|
|
8
|
+
export type ActionSheetDetent = 'auto' | 'medium' | 'large';
|
|
8
9
|
export interface ActionSheetCommonOptionsInterface extends BaseOptionsInterface {
|
|
9
10
|
options: ActionSheetButtonInterface[];
|
|
10
11
|
anchor?: ActionSheetAnchorInterface | {
|
|
11
12
|
current: ActionSheetAnchorInterface | null;
|
|
12
13
|
} | null;
|
|
13
|
-
presentationStyle?: 'centered' | 'anchored';
|
|
14
|
+
presentationStyle?: 'centered' | 'anchored' | 'bottom';
|
|
15
|
+
detents?: ActionSheetDetent[];
|
|
14
16
|
}
|
|
15
17
|
export interface ActionSheetAndroidOptionsInterface extends BaseAndroidOptionsInterface {
|
|
16
18
|
anchorAlignment?: 'start' | 'center';
|
|
17
19
|
}
|
|
18
20
|
export interface ActionSheetOptionsInterface extends ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface {
|
|
19
21
|
}
|
|
22
|
+
export type ActionSheetResultInterface = CloseResultInterface;
|
|
20
23
|
//# sourceMappingURL=action-sheet-options.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,KACpE,IAAI,CAAC;CACX;
|
|
1
|
+
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,KACpE,IAAI,CAAC;CACX;AAID,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,iCAAkC,SAAQ,oBAAoB;IAC7E,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,MAAM,CAAC,EACH,0BAA0B,GAC1B;QAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAA;KAAE,GAC9C,IAAI,CAAC;IACT,iBAAiB,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IAIvD,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,kCAAmC,SAAQ,2BAA2B;IACrF,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACtC;AAED,MAAM,WAAW,2BACf,SACE,iCAAiC,EACjC,kCAAkC;CAAG;AAEzC,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC"}
|
|
@@ -2,6 +2,7 @@ export interface BaseButtonInterface {
|
|
|
2
2
|
label: string;
|
|
3
3
|
style?: 'cancel' | 'destructive';
|
|
4
4
|
disabled?: boolean;
|
|
5
|
+
preferred?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export interface BaseOptionsInterface {
|
|
7
8
|
title?: string;
|
|
@@ -14,4 +15,12 @@ export interface BaseOptionsInterface {
|
|
|
14
15
|
export interface BaseAndroidOptionsInterface {
|
|
15
16
|
buttonTextAlignment?: 'start' | 'center';
|
|
16
17
|
}
|
|
18
|
+
export type CloseReason = 'selected' | 'cancelled' | 'dismissed';
|
|
19
|
+
export type CloseResultInterface = {
|
|
20
|
+
reason: 'selected' | 'cancelled';
|
|
21
|
+
buttonIndex: number;
|
|
22
|
+
} | {
|
|
23
|
+
reason: 'dismissed';
|
|
24
|
+
buttonIndex: undefined;
|
|
25
|
+
};
|
|
17
26
|
//# sourceMappingURL=common-options.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/common-options.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"common-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/common-options.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,2BAA2B;IAC1C,mBAAmB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC1C;AAOD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAIjE,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ActionSheetOptionsInterface } from './action-sheet-options.interface';
|
|
2
|
-
export type { BaseButtonInterface, BaseOptionsInterface, BaseAndroidOptionsInterface, } from './common-options.interface';
|
|
3
|
-
export type { PromptButtonInterface, PromptCommonOptionsInterface, PromptAndroidOptionsInterface, PromptOptionsInterface, PromptResultInterface, } from './prompt-options.interface';
|
|
1
|
+
import type { ActionSheetOptionsInterface, ActionSheetResultInterface } from './action-sheet-options.interface';
|
|
4
2
|
import type { PromptOptionsInterface, PromptResultInterface } from './prompt-options.interface';
|
|
5
|
-
export type {
|
|
6
|
-
export
|
|
3
|
+
export type { BaseButtonInterface, BaseOptionsInterface, BaseAndroidOptionsInterface, CloseReason, CloseResultInterface, } from './common-options.interface';
|
|
4
|
+
export type { PromptButtonInterface, PromptCommonOptionsInterface, PromptAndroidOptionsInterface, PromptOptionsInterface, PromptResultInterface, PromptValuesInterface, } from './prompt-options.interface';
|
|
5
|
+
export type { ActionSheetAnchorInterface, ActionSheetButtonInterface, ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface, ActionSheetDetent, ActionSheetOptionsInterface, ActionSheetResultInterface, } from './action-sheet-options.interface';
|
|
6
|
+
export declare const showActionSheetWithOptions: (options: ActionSheetOptionsInterface) => Promise<ActionSheetResultInterface>;
|
|
7
7
|
export declare const dismissActionSheet: () => void;
|
|
8
8
|
export declare const dismissAllActionSheets: () => void;
|
|
9
|
-
export declare const showPromptWithOptions: (options: PromptOptionsInterface) => Promise<PromptResultInterface
|
|
9
|
+
export declare const showPromptWithOptions: (options: PromptOptionsInterface) => Promise<PromptResultInterface>;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,kCAAkC,CAAC;AAK1C,OAAO,KAAK,EAEV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,WAAW,EACX,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,kCAAkC,EAClC,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAiK1C,eAAO,MAAM,0BAA0B,GACrC,SAAS,2BAA2B,KACnC,OAAO,CAAC,0BAA0B,CAwBpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,IAIrC,CAAC;AAIF,eAAO,MAAM,sBAAsB,QAAO,IAIzC,CAAC;AAMF,eAAO,MAAM,qBAAqB,GAChC,SAAS,sBAAsB,KAC9B,OAAO,CAAC,qBAAqB,CA8C/B,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface';
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface, CloseResultInterface } from './common-options.interface';
|
|
2
|
+
export interface PromptValuesInterface {
|
|
3
|
+
text: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
}
|
|
2
6
|
export interface PromptButtonInterface extends BaseButtonInterface {
|
|
3
|
-
onPress?: (
|
|
7
|
+
onPress?: (values: PromptValuesInterface) => void;
|
|
8
|
+
requiresText?: boolean;
|
|
4
9
|
}
|
|
5
10
|
export interface PromptCommonOptionsInterface extends BaseOptionsInterface {
|
|
6
11
|
options: PromptButtonInterface[];
|
|
12
|
+
type?: 'plain-text' | 'secure-text' | 'login-password';
|
|
7
13
|
placeholder?: string;
|
|
14
|
+
passwordPlaceholder?: string;
|
|
8
15
|
defaultValue?: string;
|
|
9
16
|
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'url';
|
|
10
17
|
secureTextEntry?: boolean;
|
|
@@ -12,8 +19,5 @@ export interface PromptCommonOptionsInterface extends BaseOptionsInterface {
|
|
|
12
19
|
export type PromptAndroidOptionsInterface = BaseAndroidOptionsInterface;
|
|
13
20
|
export interface PromptOptionsInterface extends PromptCommonOptionsInterface, PromptAndroidOptionsInterface {
|
|
14
21
|
}
|
|
15
|
-
export
|
|
16
|
-
buttonIndex: number;
|
|
17
|
-
text: string;
|
|
18
|
-
}
|
|
22
|
+
export type PromptResultInterface = CloseResultInterface & PromptValuesInterface;
|
|
19
23
|
//# sourceMappingURL=prompt-options.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/prompt-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/prompt-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAGlD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,OAAO,EAAE,qBAAqB,EAAE,CAAC;IAGjC,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,gBAAgB,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;IAG7E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAExE,MAAM,WAAW,sBACf,SAAQ,4BAA4B,EAAE,6BAA6B;CAAG;AAExE,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GACtD,qBAAqB,CAAC"}
|