@thunderid/vue 0.13.2 → 1.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/cjs/index.cjs +68 -12
- package/dist/components/actions/SignInButton.d.ts +15 -0
- package/dist/components/actions/SignInButton.d.ts.map +1 -1
- package/dist/components/actions/SignUpButton.d.ts +15 -0
- package/dist/components/actions/SignUpButton.d.ts.map +1 -1
- package/dist/components/factories/FieldFactory.d.ts +2 -0
- package/dist/components/factories/FieldFactory.d.ts.map +1 -1
- package/dist/components/primitives/OtpField/OtpField.d.ts.map +1 -1
- package/dist/index.js +68 -12
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -4400,6 +4400,8 @@ var DatePicker_default = DatePicker;
|
|
|
4400
4400
|
|
|
4401
4401
|
//#endregion
|
|
4402
4402
|
//#region src/components/primitives/OtpField/OtpField.ts
|
|
4403
|
+
const NON_NUMERIC_OTP_CHARS = /[^0-9]/g;
|
|
4404
|
+
const NON_ALPHANUMERIC_OTP_CHARS = /[^0-9A-Z]/g;
|
|
4403
4405
|
const OtpField = (0, vue.defineComponent)({
|
|
4404
4406
|
name: "OtpField",
|
|
4405
4407
|
props: {
|
|
@@ -4427,6 +4429,10 @@ const OtpField = (0, vue.defineComponent)({
|
|
|
4427
4429
|
default: void 0,
|
|
4428
4430
|
type: String
|
|
4429
4431
|
},
|
|
4432
|
+
numericOnly: {
|
|
4433
|
+
default: true,
|
|
4434
|
+
type: Boolean
|
|
4435
|
+
},
|
|
4430
4436
|
required: {
|
|
4431
4437
|
default: false,
|
|
4432
4438
|
type: Boolean
|
|
@@ -4440,7 +4446,7 @@ const OtpField = (0, vue.defineComponent)({
|
|
|
4440
4446
|
};
|
|
4441
4447
|
const handleInput = (index, e) => {
|
|
4442
4448
|
const target = e.target;
|
|
4443
|
-
const val = target.value.replace(
|
|
4449
|
+
const val = props.numericOnly ? target.value.replace(NON_NUMERIC_OTP_CHARS, "").slice(0, 1) : target.value.toUpperCase().replace(NON_ALPHANUMERIC_OTP_CHARS, "").slice(0, 1);
|
|
4444
4450
|
target.value = val;
|
|
4445
4451
|
const current = (props.modelValue || "").split("");
|
|
4446
4452
|
while (current.length < props.length) current.push("");
|
|
@@ -4463,7 +4469,7 @@ const OtpField = (0, vue.defineComponent)({
|
|
|
4463
4469
|
"aria-label": `Digit ${i + 1}`,
|
|
4464
4470
|
class: (0, __thunderid_browser.withVendorCSSClassPrefix)("otp-field__digit"),
|
|
4465
4471
|
disabled: props.disabled,
|
|
4466
|
-
inputmode: "numeric",
|
|
4472
|
+
inputmode: props.numericOnly ? "numeric" : "text",
|
|
4467
4473
|
key: i,
|
|
4468
4474
|
maxlength: 1,
|
|
4469
4475
|
onInput: (e) => handleInput(i, e),
|
|
@@ -4715,13 +4721,34 @@ var BaseSignInButton_default = BaseSignInButton;
|
|
|
4715
4721
|
*
|
|
4716
4722
|
* If a custom `signInUrl` is configured, navigates to it instead.
|
|
4717
4723
|
* Falls back to i18n translation for the button text.
|
|
4724
|
+
*
|
|
4725
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
4726
|
+
* {@link BaseSignInButton}'s convention) — the click handler and styling are
|
|
4727
|
+
* wired up for you.
|
|
4728
|
+
*
|
|
4729
|
+
* @example
|
|
4730
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
4731
|
+
* <SignInButton>Sign In</SignInButton>
|
|
4732
|
+
* <SignInButton v-slot="{ isLoading }">{{ isLoading ? 'Signing in…' : 'Sign in' }}</SignInButton>
|
|
4733
|
+
*
|
|
4734
|
+
* @example
|
|
4735
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
4736
|
+
* <SignInButton as-child v-slot="{ signIn, isLoading }">
|
|
4737
|
+
* <button @click="signIn" :disabled="isLoading">Sign In</button>
|
|
4738
|
+
* </SignInButton>
|
|
4718
4739
|
*/
|
|
4719
4740
|
const SignInButton = (0, vue.defineComponent)({
|
|
4720
4741
|
name: "SignInButton",
|
|
4721
|
-
props: {
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4742
|
+
props: {
|
|
4743
|
+
asChild: {
|
|
4744
|
+
default: false,
|
|
4745
|
+
type: Boolean
|
|
4746
|
+
},
|
|
4747
|
+
signInOptions: {
|
|
4748
|
+
default: void 0,
|
|
4749
|
+
type: Object
|
|
4750
|
+
}
|
|
4751
|
+
},
|
|
4725
4752
|
emits: ["click", "error"],
|
|
4726
4753
|
setup(props, { slots, emit, attrs }) {
|
|
4727
4754
|
const { signIn, signInUrl, signInOptions: contextSignInOptions } = useThunderID_default();
|
|
@@ -4740,19 +4767,23 @@ const SignInButton = (0, vue.defineComponent)({
|
|
|
4740
4767
|
}
|
|
4741
4768
|
};
|
|
4742
4769
|
return () => {
|
|
4743
|
-
if (slots["default"]) {
|
|
4770
|
+
if (props.asChild && slots["default"]) {
|
|
4744
4771
|
const nodes = slots["default"]({
|
|
4745
4772
|
isLoading: isLoading.value,
|
|
4746
4773
|
signIn: handleSignIn
|
|
4747
4774
|
});
|
|
4748
4775
|
return nodes.length === 1 ? nodes[0] : (0, vue.h)(vue.Fragment, null, nodes);
|
|
4749
4776
|
}
|
|
4777
|
+
const slotContent = slots["default"] ? () => slots["default"]({
|
|
4778
|
+
isLoading: isLoading.value,
|
|
4779
|
+
signIn: handleSignIn
|
|
4780
|
+
}) : void 0;
|
|
4750
4781
|
return (0, vue.h)(BaseSignInButton_default, {
|
|
4751
4782
|
class: attrs.class,
|
|
4752
4783
|
isLoading: isLoading.value,
|
|
4753
4784
|
onClick: handleSignIn,
|
|
4754
4785
|
style: attrs.style
|
|
4755
|
-
});
|
|
4786
|
+
}, slotContent);
|
|
4756
4787
|
};
|
|
4757
4788
|
}
|
|
4758
4789
|
});
|
|
@@ -4919,11 +4950,30 @@ var BaseSignUpButton_default = BaseSignUpButton;
|
|
|
4919
4950
|
*
|
|
4920
4951
|
* If a custom `signUpUrl` is configured, navigates to it instead.
|
|
4921
4952
|
* Falls back to i18n translation for the button text.
|
|
4953
|
+
*
|
|
4954
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
4955
|
+
* {@link BaseSignUpButton}'s convention) — the click handler and styling are
|
|
4956
|
+
* wired up for you.
|
|
4957
|
+
*
|
|
4958
|
+
* @example
|
|
4959
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
4960
|
+
* <SignUpButton>Sign Up</SignUpButton>
|
|
4961
|
+
* <SignUpButton v-slot="{ isLoading }">{{ isLoading ? 'Signing up…' : 'Sign up' }}</SignUpButton>
|
|
4962
|
+
*
|
|
4963
|
+
* @example
|
|
4964
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
4965
|
+
* <SignUpButton as-child v-slot="{ signUp, isLoading }">
|
|
4966
|
+
* <button @click="signUp" :disabled="isLoading">Sign Up</button>
|
|
4967
|
+
* </SignUpButton>
|
|
4922
4968
|
*/
|
|
4923
4969
|
const SignUpButton = (0, vue.defineComponent)({
|
|
4924
4970
|
name: "SignUpButton",
|
|
4971
|
+
props: { asChild: {
|
|
4972
|
+
default: false,
|
|
4973
|
+
type: Boolean
|
|
4974
|
+
} },
|
|
4925
4975
|
emits: ["click", "error"],
|
|
4926
|
-
setup(
|
|
4976
|
+
setup(props, { slots, emit, attrs }) {
|
|
4927
4977
|
const { signUp, signUpUrl } = useThunderID_default();
|
|
4928
4978
|
const isLoading = (0, vue.ref)(false);
|
|
4929
4979
|
const handleSignUp = async (e) => {
|
|
@@ -4940,19 +4990,23 @@ const SignUpButton = (0, vue.defineComponent)({
|
|
|
4940
4990
|
}
|
|
4941
4991
|
};
|
|
4942
4992
|
return () => {
|
|
4943
|
-
if (slots["default"]) {
|
|
4993
|
+
if (props.asChild && slots["default"]) {
|
|
4944
4994
|
const nodes = slots["default"]({
|
|
4945
4995
|
isLoading: isLoading.value,
|
|
4946
4996
|
signUp: handleSignUp
|
|
4947
4997
|
});
|
|
4948
4998
|
return nodes.length === 1 ? nodes[0] : (0, vue.h)(vue.Fragment, null, nodes);
|
|
4949
4999
|
}
|
|
5000
|
+
const slotContent = slots["default"] ? () => slots["default"]({
|
|
5001
|
+
isLoading: isLoading.value,
|
|
5002
|
+
signUp: handleSignUp
|
|
5003
|
+
}) : void 0;
|
|
4950
5004
|
return (0, vue.h)(BaseSignUpButton_default, {
|
|
4951
5005
|
class: attrs.class,
|
|
4952
5006
|
isLoading: isLoading.value,
|
|
4953
5007
|
onClick: handleSignUp,
|
|
4954
5008
|
style: attrs.style
|
|
4955
|
-
});
|
|
5009
|
+
}, slotContent);
|
|
4956
5010
|
};
|
|
4957
5011
|
}
|
|
4958
5012
|
});
|
|
@@ -5637,7 +5691,7 @@ const validateFieldValue = (value, type, required = false, touched = false) => {
|
|
|
5637
5691
|
* Factory function to create form field VNodes based on FieldType.
|
|
5638
5692
|
*/
|
|
5639
5693
|
const createField = (config) => {
|
|
5640
|
-
const { name, type, label, required, value, onChange, onBlur, disabled = false, error, className, options = [], touched = false, placeholder } = config;
|
|
5694
|
+
const { name, type, label, required, value, onChange, onBlur, disabled = false, error, className, options = [], touched = false, placeholder, length, numericOnly = true } = config;
|
|
5641
5695
|
const validationError = error || validateFieldValue(value, type, required, touched);
|
|
5642
5696
|
const commonProps = {
|
|
5643
5697
|
class: className,
|
|
@@ -5682,6 +5736,8 @@ const createField = (config) => {
|
|
|
5682
5736
|
}
|
|
5683
5737
|
case __thunderid_browser.FieldType.Otp: return (0, vue.h)(OtpField_default, {
|
|
5684
5738
|
...commonProps,
|
|
5739
|
+
...length ? { length } : {},
|
|
5740
|
+
numericOnly,
|
|
5685
5741
|
"onUpdate:modelValue": onChange
|
|
5686
5742
|
});
|
|
5687
5743
|
case __thunderid_browser.FieldType.Number: return (0, vue.h)(TextField_default, {
|
|
@@ -4,6 +4,21 @@ import { type Component } from 'vue';
|
|
|
4
4
|
*
|
|
5
5
|
* If a custom `signInUrl` is configured, navigates to it instead.
|
|
6
6
|
* Falls back to i18n translation for the button text.
|
|
7
|
+
*
|
|
8
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
9
|
+
* {@link BaseSignInButton}'s convention) — the click handler and styling are
|
|
10
|
+
* wired up for you.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
14
|
+
* <SignInButton>Sign In</SignInButton>
|
|
15
|
+
* <SignInButton v-slot="{ isLoading }">{{ isLoading ? 'Signing in…' : 'Sign in' }}</SignInButton>
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
19
|
+
* <SignInButton as-child v-slot="{ signIn, isLoading }">
|
|
20
|
+
* <button @click="signIn" :disabled="isLoading">Sign In</button>
|
|
21
|
+
* </SignInButton>
|
|
7
22
|
*/
|
|
8
23
|
declare const SignInButton: Component;
|
|
9
24
|
export default SignInButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInButton.d.ts","sourceRoot":"","sources":["../../../src/components/actions/SignInButton.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,SAAS,EAKf,MAAM,KAAK,CAAC;AAIb
|
|
1
|
+
{"version":3,"file":"SignInButton.d.ts","sourceRoot":"","sources":["../../../src/components/actions/SignInButton.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,SAAS,EAKf,MAAM,KAAK,CAAC;AAIb;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,YAAY,EAAE,SA6DlB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -4,6 +4,21 @@ import { type Component } from 'vue';
|
|
|
4
4
|
*
|
|
5
5
|
* If a custom `signUpUrl` is configured, navigates to it instead.
|
|
6
6
|
* Falls back to i18n translation for the button text.
|
|
7
|
+
*
|
|
8
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
9
|
+
* {@link BaseSignUpButton}'s convention) — the click handler and styling are
|
|
10
|
+
* wired up for you.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
14
|
+
* <SignUpButton>Sign Up</SignUpButton>
|
|
15
|
+
* <SignUpButton v-slot="{ isLoading }">{{ isLoading ? 'Signing up…' : 'Sign up' }}</SignUpButton>
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
19
|
+
* <SignUpButton as-child v-slot="{ signUp, isLoading }">
|
|
20
|
+
* <button @click="signUp" :disabled="isLoading">Sign Up</button>
|
|
21
|
+
* </SignUpButton>
|
|
7
22
|
*/
|
|
8
23
|
declare const SignUpButton: Component;
|
|
9
24
|
export default SignUpButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUpButton.d.ts","sourceRoot":"","sources":["../../../src/components/actions/SignUpButton.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,SAAS,EAA0C,MAAM,KAAK,CAAC;AAI/G
|
|
1
|
+
{"version":3,"file":"SignUpButton.d.ts","sourceRoot":"","sources":["../../../src/components/actions/SignUpButton.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,SAAS,EAA0C,MAAM,KAAK,CAAC;AAI/G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,YAAY,EAAE,SAyDlB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldFactory.d.ts","sourceRoot":"","sources":["../../../src/components/factories/FieldFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,KAAK,SAAS,EAAiB,KAAK,KAAK,EAAqB,MAAM,KAAK,CAAC;AAKlF,OAAe,EAAC,KAAK,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAgBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,MAAM,SAAS,EACf,kBAAgB,EAChB,iBAAe,KACd,MAAM,GAAG,IAsBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"FieldFactory.d.ts","sourceRoot":"","sources":["../../../src/components/factories/FieldFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,KAAK,SAAS,EAAiB,KAAK,KAAK,EAAqB,MAAM,KAAK,CAAC;AAKlF,OAAe,EAAC,KAAK,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAgBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,MAAM,SAAS,EACf,kBAAgB,EAChB,iBAAe,KACd,MAAM,GAAG,IAsBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,KAAG,KAsHjD,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,SAkClB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtpField.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/OtpField/OtpField.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,SAAS,EAA6E,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"OtpField.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/OtpField/OtpField.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,SAAS,EAA6E,MAAM,KAAK,CAAC;AAkB/G,QAAA,MAAM,QAAQ,EAAE,SAqFd,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4374,6 +4374,8 @@ var DatePicker_default = DatePicker;
|
|
|
4374
4374
|
|
|
4375
4375
|
//#endregion
|
|
4376
4376
|
//#region src/components/primitives/OtpField/OtpField.ts
|
|
4377
|
+
const NON_NUMERIC_OTP_CHARS = /[^0-9]/g;
|
|
4378
|
+
const NON_ALPHANUMERIC_OTP_CHARS = /[^0-9A-Z]/g;
|
|
4377
4379
|
const OtpField = defineComponent({
|
|
4378
4380
|
name: "OtpField",
|
|
4379
4381
|
props: {
|
|
@@ -4401,6 +4403,10 @@ const OtpField = defineComponent({
|
|
|
4401
4403
|
default: void 0,
|
|
4402
4404
|
type: String
|
|
4403
4405
|
},
|
|
4406
|
+
numericOnly: {
|
|
4407
|
+
default: true,
|
|
4408
|
+
type: Boolean
|
|
4409
|
+
},
|
|
4404
4410
|
required: {
|
|
4405
4411
|
default: false,
|
|
4406
4412
|
type: Boolean
|
|
@@ -4414,7 +4420,7 @@ const OtpField = defineComponent({
|
|
|
4414
4420
|
};
|
|
4415
4421
|
const handleInput = (index, e) => {
|
|
4416
4422
|
const target = e.target;
|
|
4417
|
-
const val = target.value.replace(
|
|
4423
|
+
const val = props.numericOnly ? target.value.replace(NON_NUMERIC_OTP_CHARS, "").slice(0, 1) : target.value.toUpperCase().replace(NON_ALPHANUMERIC_OTP_CHARS, "").slice(0, 1);
|
|
4418
4424
|
target.value = val;
|
|
4419
4425
|
const current = (props.modelValue || "").split("");
|
|
4420
4426
|
while (current.length < props.length) current.push("");
|
|
@@ -4437,7 +4443,7 @@ const OtpField = defineComponent({
|
|
|
4437
4443
|
"aria-label": `Digit ${i + 1}`,
|
|
4438
4444
|
class: withVendorCSSClassPrefix("otp-field__digit"),
|
|
4439
4445
|
disabled: props.disabled,
|
|
4440
|
-
inputmode: "numeric",
|
|
4446
|
+
inputmode: props.numericOnly ? "numeric" : "text",
|
|
4441
4447
|
key: i,
|
|
4442
4448
|
maxlength: 1,
|
|
4443
4449
|
onInput: (e) => handleInput(i, e),
|
|
@@ -4689,13 +4695,34 @@ var BaseSignInButton_default = BaseSignInButton;
|
|
|
4689
4695
|
*
|
|
4690
4696
|
* If a custom `signInUrl` is configured, navigates to it instead.
|
|
4691
4697
|
* Falls back to i18n translation for the button text.
|
|
4698
|
+
*
|
|
4699
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
4700
|
+
* {@link BaseSignInButton}'s convention) — the click handler and styling are
|
|
4701
|
+
* wired up for you.
|
|
4702
|
+
*
|
|
4703
|
+
* @example
|
|
4704
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
4705
|
+
* <SignInButton>Sign In</SignInButton>
|
|
4706
|
+
* <SignInButton v-slot="{ isLoading }">{{ isLoading ? 'Signing in…' : 'Sign in' }}</SignInButton>
|
|
4707
|
+
*
|
|
4708
|
+
* @example
|
|
4709
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
4710
|
+
* <SignInButton as-child v-slot="{ signIn, isLoading }">
|
|
4711
|
+
* <button @click="signIn" :disabled="isLoading">Sign In</button>
|
|
4712
|
+
* </SignInButton>
|
|
4692
4713
|
*/
|
|
4693
4714
|
const SignInButton = defineComponent({
|
|
4694
4715
|
name: "SignInButton",
|
|
4695
|
-
props: {
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4716
|
+
props: {
|
|
4717
|
+
asChild: {
|
|
4718
|
+
default: false,
|
|
4719
|
+
type: Boolean
|
|
4720
|
+
},
|
|
4721
|
+
signInOptions: {
|
|
4722
|
+
default: void 0,
|
|
4723
|
+
type: Object
|
|
4724
|
+
}
|
|
4725
|
+
},
|
|
4699
4726
|
emits: ["click", "error"],
|
|
4700
4727
|
setup(props, { slots, emit, attrs }) {
|
|
4701
4728
|
const { signIn, signInUrl, signInOptions: contextSignInOptions } = useThunderID_default();
|
|
@@ -4714,19 +4741,23 @@ const SignInButton = defineComponent({
|
|
|
4714
4741
|
}
|
|
4715
4742
|
};
|
|
4716
4743
|
return () => {
|
|
4717
|
-
if (slots["default"]) {
|
|
4744
|
+
if (props.asChild && slots["default"]) {
|
|
4718
4745
|
const nodes = slots["default"]({
|
|
4719
4746
|
isLoading: isLoading.value,
|
|
4720
4747
|
signIn: handleSignIn
|
|
4721
4748
|
});
|
|
4722
4749
|
return nodes.length === 1 ? nodes[0] : h(Fragment, null, nodes);
|
|
4723
4750
|
}
|
|
4751
|
+
const slotContent = slots["default"] ? () => slots["default"]({
|
|
4752
|
+
isLoading: isLoading.value,
|
|
4753
|
+
signIn: handleSignIn
|
|
4754
|
+
}) : void 0;
|
|
4724
4755
|
return h(BaseSignInButton_default, {
|
|
4725
4756
|
class: attrs.class,
|
|
4726
4757
|
isLoading: isLoading.value,
|
|
4727
4758
|
onClick: handleSignIn,
|
|
4728
4759
|
style: attrs.style
|
|
4729
|
-
});
|
|
4760
|
+
}, slotContent);
|
|
4730
4761
|
};
|
|
4731
4762
|
}
|
|
4732
4763
|
});
|
|
@@ -4893,11 +4924,30 @@ var BaseSignUpButton_default = BaseSignUpButton;
|
|
|
4893
4924
|
*
|
|
4894
4925
|
* If a custom `signUpUrl` is configured, navigates to it instead.
|
|
4895
4926
|
* Falls back to i18n translation for the button text.
|
|
4927
|
+
*
|
|
4928
|
+
* By default, slot content is rendered *inside* the styled button (matching
|
|
4929
|
+
* {@link BaseSignUpButton}'s convention) — the click handler and styling are
|
|
4930
|
+
* wired up for you.
|
|
4931
|
+
*
|
|
4932
|
+
* @example
|
|
4933
|
+
* <!-- Default: content is wrapped in the styled, click-wired button -->
|
|
4934
|
+
* <SignUpButton>Sign Up</SignUpButton>
|
|
4935
|
+
* <SignUpButton v-slot="{ isLoading }">{{ isLoading ? 'Signing up…' : 'Sign up' }}</SignUpButton>
|
|
4936
|
+
*
|
|
4937
|
+
* @example
|
|
4938
|
+
* <!-- asChild: full control — you render the element and wire the click yourself -->
|
|
4939
|
+
* <SignUpButton as-child v-slot="{ signUp, isLoading }">
|
|
4940
|
+
* <button @click="signUp" :disabled="isLoading">Sign Up</button>
|
|
4941
|
+
* </SignUpButton>
|
|
4896
4942
|
*/
|
|
4897
4943
|
const SignUpButton = defineComponent({
|
|
4898
4944
|
name: "SignUpButton",
|
|
4945
|
+
props: { asChild: {
|
|
4946
|
+
default: false,
|
|
4947
|
+
type: Boolean
|
|
4948
|
+
} },
|
|
4899
4949
|
emits: ["click", "error"],
|
|
4900
|
-
setup(
|
|
4950
|
+
setup(props, { slots, emit, attrs }) {
|
|
4901
4951
|
const { signUp, signUpUrl } = useThunderID_default();
|
|
4902
4952
|
const isLoading = ref(false);
|
|
4903
4953
|
const handleSignUp = async (e) => {
|
|
@@ -4914,19 +4964,23 @@ const SignUpButton = defineComponent({
|
|
|
4914
4964
|
}
|
|
4915
4965
|
};
|
|
4916
4966
|
return () => {
|
|
4917
|
-
if (slots["default"]) {
|
|
4967
|
+
if (props.asChild && slots["default"]) {
|
|
4918
4968
|
const nodes = slots["default"]({
|
|
4919
4969
|
isLoading: isLoading.value,
|
|
4920
4970
|
signUp: handleSignUp
|
|
4921
4971
|
});
|
|
4922
4972
|
return nodes.length === 1 ? nodes[0] : h(Fragment, null, nodes);
|
|
4923
4973
|
}
|
|
4974
|
+
const slotContent = slots["default"] ? () => slots["default"]({
|
|
4975
|
+
isLoading: isLoading.value,
|
|
4976
|
+
signUp: handleSignUp
|
|
4977
|
+
}) : void 0;
|
|
4924
4978
|
return h(BaseSignUpButton_default, {
|
|
4925
4979
|
class: attrs.class,
|
|
4926
4980
|
isLoading: isLoading.value,
|
|
4927
4981
|
onClick: handleSignUp,
|
|
4928
4982
|
style: attrs.style
|
|
4929
|
-
});
|
|
4983
|
+
}, slotContent);
|
|
4930
4984
|
};
|
|
4931
4985
|
}
|
|
4932
4986
|
});
|
|
@@ -5611,7 +5665,7 @@ const validateFieldValue = (value, type, required = false, touched = false) => {
|
|
|
5611
5665
|
* Factory function to create form field VNodes based on FieldType.
|
|
5612
5666
|
*/
|
|
5613
5667
|
const createField = (config) => {
|
|
5614
|
-
const { name, type, label, required, value, onChange, onBlur, disabled = false, error, className, options = [], touched = false, placeholder } = config;
|
|
5668
|
+
const { name, type, label, required, value, onChange, onBlur, disabled = false, error, className, options = [], touched = false, placeholder, length, numericOnly = true } = config;
|
|
5615
5669
|
const validationError = error || validateFieldValue(value, type, required, touched);
|
|
5616
5670
|
const commonProps = {
|
|
5617
5671
|
class: className,
|
|
@@ -5656,6 +5710,8 @@ const createField = (config) => {
|
|
|
5656
5710
|
}
|
|
5657
5711
|
case FieldType$1.Otp: return h(OtpField_default, {
|
|
5658
5712
|
...commonProps,
|
|
5713
|
+
...length ? { length } : {},
|
|
5714
|
+
numericOnly,
|
|
5659
5715
|
"onUpdate:modelValue": onChange
|
|
5660
5716
|
});
|
|
5661
5717
|
case FieldType$1.Number: return h(TextField_default, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thunderid/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Vue SDK for ThunderID",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"thunderid",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"dompurify": "3.4.11",
|
|
61
61
|
"tslib": "2.8.1",
|
|
62
|
-
"@thunderid/browser": "^0.
|
|
62
|
+
"@thunderid/browser": "^1.0.0"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|