-
-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f95fcb
commit 85c74e0
Showing
54 changed files
with
2,621 additions
and
2,939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ | |
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
5 changes: 4 additions & 1 deletion
5
example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
abstract class Element {} | ||
extension type const Element._(Object o) implements Object {} | ||
|
||
abstract class Elements {} | ||
extension type const Elements._(Object o) implements Object {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,28 @@ | ||
import 'package:js/js.dart'; | ||
import 'package:stripe_js/stripe_api.dart'; | ||
import 'dart:js_interop'; | ||
import '../utils/utils.dart'; | ||
|
||
typedef EventCallback<T> = void Function(T event); | ||
|
||
@anonymous | ||
@JS() | ||
abstract class StripeElement implements Element { | ||
extension type const StripeElement(JSObject o) implements JSObject, Element { | ||
/// HTMLElement keeps giving this error for some reason: | ||
/// Cannot find name 'HTMLElement' | ||
external void mount(dynamic domElement); | ||
/*external void on('blur'|'change'|'focus'|'ready' event, handler handler);*/ | ||
/*external void on('click' event, void handler({ preventDefault: () => void } response));*/ | ||
external void mount(JSAny domElement); | ||
|
||
/*external void addEventJsArrayener('blur'|'change'|'focus'|'ready' event, handler handler);*/ | ||
/*external void addEventJsArrayener('click' event, void handler({ preventDefault: () => void } response));*/ | ||
external void addEventJsArrayener( | ||
String event, EventCallback<dynamic> handler); | ||
external void focus(); | ||
external void blur(); | ||
external void clear(); | ||
external void unmount(); | ||
external void destroy(); | ||
|
||
@JS("on") | ||
external void on(String event, EventCallback<dynamic> handler); | ||
} | ||
|
||
extension ElementExtension on StripeElement { | ||
void onFocus(EventCallback<dynamic> onEvent) { | ||
return on("focus", allowInterop((e) { | ||
onEvent(e); | ||
})); | ||
} | ||
external void _on(String event, JSExportedDartFunction handler); | ||
|
||
void onReady(EventCallback<dynamic> onEvent) { | ||
return on("ready", allowInterop((e) { | ||
onEvent(e); | ||
})); | ||
void on(String event, EventCallback<JSMap> handler) { | ||
return _on(event, handler.toJS); | ||
} | ||
|
||
void onBlur(EventCallback<dynamic> onEvent) { | ||
return on("blur", allowInterop((e) { | ||
onEvent(e); | ||
})); | ||
} | ||
void onFocus(EventCallback<void> onEvent) => on("focus", onEvent); | ||
void onReady(EventCallback<void> onEvent) => on("ready", onEvent); | ||
void onBlur(EventCallback<void> onEvent) => on("blur", onEvent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 26 additions & 18 deletions
44
packages/stripe_js/lib/src/js/elements/element_creation_options.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
// Module elements | ||
import 'dart:js'; | ||
|
||
import 'package:js/js.dart'; | ||
import 'package:stripe_js/stripe_js.dart'; | ||
import 'dart:js_interop'; | ||
|
||
@anonymous | ||
@JS() | ||
abstract class JsElementsCreateOptions { | ||
@JS("ElementsCreateOptions") | ||
extension type JsElementsCreateOptions._(JSObject o) { | ||
external factory JsElementsCreateOptions({ | ||
JsArray<Font>? fonts, | ||
JSArray<Font>? fonts, | ||
String? locale, | ||
String? clientSecret, | ||
JsElementAppearance? appearance, | ||
String loader = "auto", | ||
String loader, | ||
}); | ||
|
||
external JsArray<Font> fonts; | ||
external JSArray<Font> fonts; | ||
external String locale; | ||
external String clientSecret; | ||
external JsElementAppearance appearance; | ||
} | ||
|
||
@anonymous | ||
@JS() | ||
class JsElementAppearance { | ||
external String? theme; | ||
external Map<String, String>? variables; | ||
external Map<String, Map<String, String>>? rules; | ||
external String? labels; | ||
@JS("ElementAppearance") | ||
external factory JsElementAppearance({ | ||
extension type JsElementAppearance._(JSObject o) { | ||
factory JsElementAppearance({ | ||
String? theme, | ||
Map<String, String>? variables, | ||
Map<String, Map<String, String>>? rules, | ||
String? labels, | ||
}) { | ||
return JsElementAppearance.__( | ||
theme: theme, | ||
variables: variables.jsify(), | ||
rules: rules.jsify(), | ||
labels: labels, | ||
); | ||
} | ||
|
||
external JsElementAppearance.__({ | ||
String? theme, | ||
JSAny? variables, | ||
JSAny? rules, | ||
String? labels, | ||
}); | ||
|
||
external String? theme; | ||
external JSAny? variables; | ||
external JSAny? rules; | ||
external String? labels; | ||
} |
31 changes: 13 additions & 18 deletions
31
packages/stripe_js/lib/src/js/elements/element_payment.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
import 'package:js/js.dart'; | ||
import 'dart:js_interop'; | ||
|
||
import 'package:stripe_js/stripe_api.dart'; | ||
import 'package:stripe_js/stripe_js.dart'; | ||
|
||
extension ElementsPaymentExtension on StripeElements { | ||
/// This method creates an instance of the Payment Element. | ||
/// [options] : Options for creating the Payment Element. | ||
PaymentElement createPayment([PaymentElementOptions? options]) { | ||
return create('payment', jsify(options?.toJson() ?? {})) as PaymentElement; | ||
return create('payment', (options?.toJson() ?? {}).jsify()) | ||
as PaymentElement; | ||
} | ||
|
||
PaymentElement? getPayment([PaymentElementOptions? options]) { | ||
return getElement('payment') as PaymentElement; | ||
} | ||
} | ||
|
||
@anonymous | ||
@JS() | ||
abstract class PaymentElement extends StripeElement { | ||
extension type PaymentElement(StripeElement o) implements StripeElement { | ||
/// Updates the options the Payment Element was initialized with. | ||
/// Updates are merged into the existing configuration. | ||
@JS('update') | ||
external void _update([JSAny? options]); | ||
|
||
external void update([dynamic options]); | ||
|
||
external void collapse(); | ||
} | ||
|
||
extension ExtendedPaymentElement on PaymentElement { | ||
PaymentElement get js => this; | ||
void update([PaymentElementOptions? options]) { | ||
return update(jsify(options?.toJson() ?? {})); | ||
return _update((options?.toJson() ?? {}).jsify()); | ||
} | ||
|
||
external void collapse(); | ||
|
||
void onChange(EventCallback<PaymentElementChangeEvent> onEvent) { | ||
return on("change", allowInterop((e) { | ||
final value = dartify(e) as Map<dynamic, dynamic>; | ||
final json = value.cast<String, dynamic>(); | ||
onEvent(PaymentElementChangeEvent.fromJson(json)); | ||
})); | ||
return on("change", (event) { | ||
onEvent(PaymentElementChangeEvent.fromJson(event.toDart)); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.