@unidy.io/sdk 1.1.4 → 1.2.0-alpha2
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/app-globals-DSKjcXX_.js.map +1 -1
- package/dist/cjs/{auth-store-BaxuIp4z.js → auth-store-DC9EVec8.js} +2 -3
- package/dist/cjs/auth-store-DC9EVec8.js.map +1 -0
- package/dist/cjs/{i18n-BoDZ8kd2.js → i18n-BAZB-eHh.js} +2 -8
- package/dist/cjs/{i18n-BoDZ8kd2.js.map → i18n-BAZB-eHh.js.map} +1 -1
- package/dist/cjs/{index-R2MKLaem.js → index-CvFbf5-D.js} +1477 -1105
- package/dist/cjs/index-CvFbf5-D.js.map +1 -0
- package/dist/cjs/index.cjs.js +6 -5
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{newsletter-helpers-DR0vsegt.js → newsletter-helpers-Dj0yYHZf.js} +61 -74
- package/dist/cjs/newsletter-helpers-Dj0yYHZf.js.map +1 -0
- package/dist/cjs/{profile-helpers-B2h2III_.js → profile-helpers-D66Ycaft.js} +3 -3
- package/dist/cjs/{profile-helpers-B2h2III_.js.map → profile-helpers-D66Ycaft.js.map} +1 -1
- package/dist/cjs/u-conditional-render.cjs.entry.js +5 -6
- package/dist/cjs/u-conditional-render.entry.cjs.js.map +1 -1
- package/dist/cjs/u-config.cjs.entry.js +5 -6
- package/dist/cjs/u-config.entry.cjs.js.map +1 -1
- package/dist/cjs/u-email-field.cjs.entry.js +2 -2
- package/dist/cjs/u-error-message.cjs.entry.js +3 -3
- package/dist/cjs/u-error-message.entry.cjs.js.map +1 -1
- package/dist/cjs/u-field.u-raw-field.entry.cjs.js.map +1 -1
- package/dist/cjs/u-field_2.cjs.entry.js +2 -2
- package/dist/cjs/u-full-profile.cjs.entry.js +1 -1
- package/dist/cjs/u-logout-button.cjs.entry.js +6 -7
- package/dist/cjs/u-logout-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-magic-code-field.cjs.entry.js +5 -6
- package/dist/cjs/u-magic-code-field.entry.cjs.js.map +1 -1
- package/dist/cjs/u-missing-field.cjs.entry.js +1 -1
- package/dist/cjs/u-missing-fields-submit-button.cjs.entry.js +9 -5
- package/dist/cjs/u-missing-fields-submit-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-checkbox.cjs.entry.js +5 -6
- package/dist/cjs/u-newsletter-checkbox.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-logout-button.cjs.entry.js +6 -7
- package/dist/cjs/u-newsletter-logout-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-preference-checkbox.cjs.entry.js +5 -6
- package/dist/cjs/u-newsletter-preference-checkbox.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-resend-doi-button.cjs.entry.js +4 -5
- package/dist/cjs/u-newsletter-resend-doi-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-root.cjs.entry.js +5 -6
- package/dist/cjs/u-newsletter-root.entry.cjs.js.map +1 -1
- package/dist/cjs/u-newsletter-toggle-subscription-button.cjs.entry.js +4 -5
- package/dist/cjs/u-newsletter-toggle-subscription-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-passkey.cjs.entry.js +5 -6
- package/dist/cjs/u-passkey.entry.cjs.js.map +1 -1
- package/dist/cjs/u-password-field.cjs.entry.js +2 -2
- package/dist/cjs/u-profile.u-submit-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-profile_2.cjs.entry.js +35 -55
- package/dist/cjs/u-registration-button.cjs.entry.js +2 -2
- package/dist/cjs/u-reset-password-button.cjs.entry.js +4 -5
- package/dist/cjs/u-reset-password-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-send-magic-code-button.cjs.entry.js +5 -6
- package/dist/cjs/u-send-magic-code-button.entry.cjs.js.map +1 -1
- package/dist/cjs/u-signed-in.cjs.entry.js +1 -1
- package/dist/cjs/u-signin-root.cjs.entry.js +1 -1
- package/dist/cjs/u-signin-step.cjs.entry.js +5 -6
- package/dist/cjs/u-signin-step.entry.cjs.js.map +1 -1
- package/dist/cjs/u-signin-strategy.cjs.entry.js +1 -1
- package/dist/cjs/u-social-login-button.cjs.entry.js +2 -2
- package/dist/cjs/u-spinner.cjs.entry.js +1 -1
- package/dist/cjs/u-spinner.entry.cjs.js.map +1 -1
- package/dist/cjs/u-ticketable-list.cjs.entry.js +39 -29
- package/dist/cjs/u-ticketable-list.entry.cjs.js.map +1 -1
- package/dist/collection/api/base-client.js +129 -0
- package/dist/collection/api/base-client.js.map +1 -0
- package/dist/collection/api/base-service.js +72 -0
- package/dist/collection/api/base-service.js.map +1 -0
- package/dist/collection/api/client.js +18 -139
- package/dist/collection/api/client.js.map +1 -1
- package/dist/collection/api/index.js +25 -5
- package/dist/collection/api/index.js.map +1 -1
- package/dist/collection/api/shared.js +11 -2
- package/dist/collection/api/shared.js.map +1 -1
- package/dist/collection/api/standalone.js +88 -0
- package/dist/collection/api/standalone.js.map +1 -0
- package/dist/collection/auth/api/auth.js +66 -124
- package/dist/collection/auth/api/auth.js.map +1 -1
- package/dist/collection/auth/api/schemas.js +78 -0
- package/dist/collection/auth/api/schemas.js.map +1 -0
- package/dist/collection/auth/auth-helpers.js +47 -36
- package/dist/collection/auth/auth-helpers.js.map +1 -1
- package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js +4 -1
- package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js.map +1 -1
- package/dist/collection/auth/components/password-field/password-field.js +1 -1
- package/dist/collection/auth/passkey-auth.js +8 -6
- package/dist/collection/auth/passkey-auth.js.map +1 -1
- package/dist/collection/auth/store/auth-store.js +0 -1
- package/dist/collection/auth/store/auth-store.js.map +1 -1
- package/dist/collection/locales/de.json +0 -1
- package/dist/collection/locales/en.json +0 -1
- package/dist/collection/locales/fr.json +0 -1
- package/dist/collection/locales/it.json +0 -1
- package/dist/collection/locales/nl_be.json +0 -1
- package/dist/collection/locales/ro.json +0 -1
- package/dist/collection/newsletter/api/newsletters.js +192 -167
- package/dist/collection/newsletter/api/newsletters.js.map +1 -1
- package/dist/collection/newsletter/api/schemas.js +112 -0
- package/dist/collection/newsletter/api/schemas.js.map +1 -0
- package/dist/collection/newsletter/newsletter-helpers.js +57 -70
- package/dist/collection/newsletter/newsletter-helpers.js.map +1 -1
- package/dist/collection/profile/api/profile.js +56 -155
- package/dist/collection/profile/api/profile.js.map +1 -1
- package/dist/collection/profile/api/schemas.js +120 -0
- package/dist/collection/profile/api/schemas.js.map +1 -0
- package/dist/collection/profile/components/field/field.css +1 -1
- package/dist/collection/profile/components/profile/profile.js +35 -101
- package/dist/collection/profile/components/profile/profile.js.map +1 -1
- package/dist/collection/shared/components/config/config.js +2 -2
- package/dist/collection/shared/components/error-message/error-message.js +3 -3
- package/dist/collection/shared/components/error-message/error-message.js.map +1 -1
- package/dist/collection/shared/components/spinner/spinner.css +1 -1
- package/dist/collection/shared/components/submit-button/submit-button.css +1 -1
- package/dist/collection/ticketable/api/schemas.js +58 -9
- package/dist/collection/ticketable/api/schemas.js.map +1 -1
- package/dist/collection/ticketable/api/subscriptions.js +13 -44
- package/dist/collection/ticketable/api/subscriptions.js.map +1 -1
- package/dist/collection/ticketable/api/ticketable-service.js +74 -0
- package/dist/collection/ticketable/api/ticketable-service.js.map +1 -0
- package/dist/collection/ticketable/api/tickets.js +13 -45
- package/dist/collection/ticketable/api/tickets.js.map +1 -1
- package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js +37 -77
- package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js.map +1 -1
- package/dist/components/auth-store.js +0 -1
- package/dist/components/auth-store.js.map +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/i18n.js +0 -6
- package/dist/components/i18n.js.map +1 -1
- package/dist/components/index.js +1 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index2.js +1475 -1106
- package/dist/components/index2.js.map +1 -1
- package/dist/components/newsletter-helpers.js +57 -70
- package/dist/components/newsletter-helpers.js.map +1 -1
- package/dist/components/profile.js +34 -54
- package/dist/components/profile.js.map +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/submit-button.js +1 -1
- package/dist/components/submit-button.js.map +1 -1
- package/dist/components/u-config.js +1 -2
- package/dist/components/u-config.js.map +1 -1
- package/dist/components/u-error-message.js +2 -2
- package/dist/components/u-error-message.js.map +1 -1
- package/dist/components/u-logout-button.js +1 -1
- package/dist/components/u-magic-code-field.js +1 -1
- package/dist/components/u-missing-fields-submit-button.js +4 -1
- package/dist/components/u-missing-fields-submit-button.js.map +1 -1
- package/dist/components/u-newsletter-root.js +1 -1
- package/dist/components/u-passkey.js +1 -1
- package/dist/components/u-reset-password-button.js +1 -1
- package/dist/components/u-send-magic-code-button.js +1 -1
- package/dist/components/u-signin-step.js +1 -1
- package/dist/components/u-ticketable-list.js +36 -29
- package/dist/components/u-ticketable-list.js.map +1 -1
- package/dist/esm/app-globals-CPU9ZcqZ.js.map +1 -1
- package/dist/esm/{auth-store-CVvBlKGv.js → auth-store-BMqUdTpC.js} +2 -3
- package/dist/esm/auth-store-BMqUdTpC.js.map +1 -0
- package/dist/esm/{i18n-CLdWzy5J.js → i18n-BANodpxG.js} +2 -8
- package/dist/esm/{i18n-CLdWzy5J.js.map → i18n-BANodpxG.js.map} +1 -1
- package/dist/esm/{index-DSDkaHWI.js → index-2p1QEJrx.js} +1477 -1108
- package/dist/esm/index-2p1QEJrx.js.map +1 -0
- package/dist/esm/index.js +3 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{newsletter-helpers-Dc_24im3.js → newsletter-helpers-D64LTcSM.js} +61 -74
- package/dist/esm/newsletter-helpers-D64LTcSM.js.map +1 -0
- package/dist/esm/{profile-helpers-CglNd6Nw.js → profile-helpers-DAvXZ9Uj.js} +3 -3
- package/dist/esm/{profile-helpers-CglNd6Nw.js.map → profile-helpers-DAvXZ9Uj.js.map} +1 -1
- package/dist/esm/u-conditional-render.entry.js +5 -6
- package/dist/esm/u-conditional-render.entry.js.map +1 -1
- package/dist/esm/u-config.entry.js +4 -5
- package/dist/esm/u-config.entry.js.map +1 -1
- package/dist/esm/u-email-field.entry.js +2 -2
- package/dist/esm/u-error-message.entry.js +3 -3
- package/dist/esm/u-error-message.entry.js.map +1 -1
- package/dist/esm/u-field.u-raw-field.entry.js.map +1 -1
- package/dist/esm/u-field_2.entry.js +2 -2
- package/dist/esm/u-full-profile.entry.js +1 -1
- package/dist/esm/u-logout-button.entry.js +5 -6
- package/dist/esm/u-logout-button.entry.js.map +1 -1
- package/dist/esm/u-magic-code-field.entry.js +4 -5
- package/dist/esm/u-magic-code-field.entry.js.map +1 -1
- package/dist/esm/u-missing-field.entry.js +1 -1
- package/dist/esm/u-missing-fields-submit-button.entry.js +9 -5
- package/dist/esm/u-missing-fields-submit-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-checkbox.entry.js +5 -6
- package/dist/esm/u-newsletter-checkbox.entry.js.map +1 -1
- package/dist/esm/u-newsletter-logout-button.entry.js +6 -7
- package/dist/esm/u-newsletter-logout-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-preference-checkbox.entry.js +5 -6
- package/dist/esm/u-newsletter-preference-checkbox.entry.js.map +1 -1
- package/dist/esm/u-newsletter-resend-doi-button.entry.js +4 -5
- package/dist/esm/u-newsletter-resend-doi-button.entry.js.map +1 -1
- package/dist/esm/u-newsletter-root.entry.js +4 -5
- package/dist/esm/u-newsletter-root.entry.js.map +1 -1
- package/dist/esm/u-newsletter-toggle-subscription-button.entry.js +4 -5
- package/dist/esm/u-newsletter-toggle-subscription-button.entry.js.map +1 -1
- package/dist/esm/u-passkey.entry.js +4 -5
- package/dist/esm/u-passkey.entry.js.map +1 -1
- package/dist/esm/u-password-field.entry.js +2 -2
- package/dist/esm/u-profile.u-submit-button.entry.js.map +1 -1
- package/dist/esm/u-profile_2.entry.js +36 -56
- package/dist/esm/u-registration-button.entry.js +2 -2
- package/dist/esm/u-reset-password-button.entry.js +3 -4
- package/dist/esm/u-reset-password-button.entry.js.map +1 -1
- package/dist/esm/u-send-magic-code-button.entry.js +4 -5
- package/dist/esm/u-send-magic-code-button.entry.js.map +1 -1
- package/dist/esm/u-signed-in.entry.js +1 -1
- package/dist/esm/u-signin-root.entry.js +1 -1
- package/dist/esm/u-signin-step.entry.js +4 -5
- package/dist/esm/u-signin-step.entry.js.map +1 -1
- package/dist/esm/u-signin-strategy.entry.js +1 -1
- package/dist/esm/u-social-login-button.entry.js +2 -2
- package/dist/esm/u-spinner.entry.js +1 -1
- package/dist/esm/u-spinner.entry.js.map +1 -1
- package/dist/esm/u-ticketable-list.entry.js +40 -30
- package/dist/esm/u-ticketable-list.entry.js.map +1 -1
- package/dist/sdk/index.esm.js +1 -1
- package/dist/sdk/index.esm.js.map +1 -1
- package/dist/sdk/locales/de.json +0 -1
- package/dist/sdk/locales/en.json +0 -1
- package/dist/sdk/locales/fr.json +0 -1
- package/dist/sdk/locales/it.json +0 -1
- package/dist/sdk/locales/nl_be.json +0 -1
- package/dist/sdk/locales/ro.json +0 -1
- package/dist/sdk/{p-5babee6b.entry.js → p-098eef67.entry.js} +2 -2
- package/dist/sdk/p-0e74de96.entry.js +2 -0
- package/dist/sdk/p-0e74de96.entry.js.map +1 -0
- package/dist/sdk/p-0ed36cbb.entry.js +2 -0
- package/dist/sdk/p-0ed36cbb.entry.js.map +1 -0
- package/dist/sdk/p-1149e044.entry.js +2 -0
- package/dist/sdk/p-1149e044.entry.js.map +1 -0
- package/dist/sdk/p-16d763fd.entry.js +2 -0
- package/dist/sdk/p-16d763fd.entry.js.map +1 -0
- package/dist/sdk/p-1d404c36.entry.js +2 -0
- package/dist/sdk/p-1d404c36.entry.js.map +1 -0
- package/dist/sdk/p-32da9922.entry.js +2 -0
- package/dist/sdk/p-32da9922.entry.js.map +1 -0
- package/dist/sdk/p-3d3a9c90.entry.js +2 -0
- package/dist/sdk/p-3d3a9c90.entry.js.map +1 -0
- package/dist/sdk/p-43024bd6.entry.js +2 -0
- package/dist/sdk/p-43024bd6.entry.js.map +1 -0
- package/dist/sdk/{p-e2e7061b.entry.js → p-5da49d00.entry.js} +2 -2
- package/dist/sdk/{p-f961fbea.entry.js → p-67af762e.entry.js} +2 -2
- package/dist/sdk/{p-f961fbea.entry.js.map → p-67af762e.entry.js.map} +1 -1
- package/dist/sdk/p-7099bd56.entry.js +2 -0
- package/dist/sdk/p-7099bd56.entry.js.map +1 -0
- package/dist/sdk/p-745742f1.entry.js +2 -0
- package/dist/sdk/{p-9e71a36c.entry.js → p-74e6523f.entry.js} +2 -2
- package/dist/sdk/p-86d16818.entry.js +2 -0
- package/dist/sdk/{p-effaf86b.entry.js.map → p-86d16818.entry.js.map} +1 -1
- package/dist/sdk/{p-DA84OuuU.js → p-BasehRhW.js} +2 -2
- package/dist/sdk/{p-DA84OuuU.js.map → p-BasehRhW.js.map} +1 -1
- package/dist/sdk/p-C4aHo4nN.js +2 -0
- package/dist/sdk/p-C4aHo4nN.js.map +1 -0
- package/dist/sdk/p-CFiZLMAA.js.map +1 -1
- package/dist/sdk/p-DGDhaqCd.js +2 -0
- package/dist/sdk/p-DGDhaqCd.js.map +1 -0
- package/dist/sdk/{p-CbRhHGU5.js → p-DSq94RWc.js} +2 -2
- package/dist/sdk/{p-CbRhHGU5.js.map → p-DSq94RWc.js.map} +1 -1
- package/dist/sdk/p-DSwwVdp1.js +2 -0
- package/dist/sdk/p-DSwwVdp1.js.map +1 -0
- package/dist/sdk/p-a037bbe3.entry.js +2 -0
- package/dist/sdk/p-a037bbe3.entry.js.map +1 -0
- package/dist/sdk/p-adcb7911.entry.js +2 -0
- package/dist/sdk/p-adcb7911.entry.js.map +1 -0
- package/dist/sdk/{p-39b61f33.entry.js → p-bbbec3d4.entry.js} +2 -2
- package/dist/sdk/{p-f232929b.entry.js → p-c2fba7c8.entry.js} +2 -2
- package/dist/sdk/p-c4618822.entry.js +2 -0
- package/dist/sdk/p-c4618822.entry.js.map +1 -0
- package/dist/sdk/p-ca4e57f2.entry.js +2 -0
- package/dist/sdk/p-ca4e57f2.entry.js.map +1 -0
- package/dist/sdk/p-ce4ab77c.entry.js +2 -0
- package/dist/sdk/p-ce4ab77c.entry.js.map +1 -0
- package/dist/sdk/p-d143e097.entry.js +2 -0
- package/dist/sdk/p-d143e097.entry.js.map +1 -0
- package/dist/sdk/{p-a69b83ec.entry.js → p-e0d2397c.entry.js} +2 -2
- package/dist/sdk/{p-80034205.entry.js → p-e6beb9d7.entry.js} +2 -2
- package/dist/sdk/p-ecc7fcff.entry.js +2 -0
- package/dist/sdk/p-ecc7fcff.entry.js.map +1 -0
- package/dist/sdk/{p-2cb6a2d0.entry.js → p-f1788e52.entry.js} +2 -2
- package/dist/sdk/p-fb665a5c.entry.js +2 -0
- package/dist/sdk/p-fb665a5c.entry.js.map +1 -0
- package/dist/sdk/p-fc67cf07.entry.js +2 -0
- package/dist/sdk/p-fc67cf07.entry.js.map +1 -0
- package/dist/sdk/sdk.esm.js +1 -1
- package/dist/sdk/u-conditional-render.entry.esm.js.map +1 -1
- package/dist/sdk/u-config.entry.esm.js.map +1 -1
- package/dist/sdk/u-error-message.entry.esm.js.map +1 -1
- package/dist/sdk/u-field.u-raw-field.entry.esm.js.map +1 -1
- package/dist/sdk/u-logout-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-magic-code-field.entry.esm.js.map +1 -1
- package/dist/sdk/u-missing-fields-submit-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-checkbox.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-logout-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-preference-checkbox.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-resend-doi-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-root.entry.esm.js.map +1 -1
- package/dist/sdk/u-newsletter-toggle-subscription-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-passkey.entry.esm.js.map +1 -1
- package/dist/sdk/u-profile.u-submit-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-reset-password-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-send-magic-code-button.entry.esm.js.map +1 -1
- package/dist/sdk/u-signin-step.entry.esm.js.map +1 -1
- package/dist/sdk/u-spinner.entry.esm.js.map +1 -1
- package/dist/sdk/u-ticketable-list.entry.esm.js.map +1 -1
- package/dist/types/api/base-client.d.ts +54 -0
- package/dist/types/api/base-service.d.ts +62 -0
- package/dist/types/api/client.d.ts +9 -31
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/shared.d.ts +11 -0
- package/dist/types/api/standalone.d.ts +105 -0
- package/dist/types/auth/api/auth.d.ts +71 -287
- package/dist/types/auth/api/schemas.d.ts +572 -0
- package/dist/types/auth/auth-helpers.d.ts +65 -66
- package/dist/types/auth/store/auth-store.d.ts +3 -3
- package/dist/types/components.d.ts +0 -72
- package/dist/types/newsletter/api/newsletters.d.ts +73 -196
- package/dist/types/newsletter/api/schemas.d.ts +192 -0
- package/dist/types/profile/api/profile.d.ts +12 -237
- package/dist/types/profile/api/schemas.d.ts +336 -0
- package/dist/types/profile/components/profile/profile.d.ts +1 -17
- package/dist/types/shared/components/error-message/error-message.d.ts +1 -1
- package/dist/types/ticketable/api/schemas.d.ts +108 -15
- package/dist/types/ticketable/api/subscriptions.d.ts +16 -83
- package/dist/types/ticketable/api/ticketable-service.d.ts +39 -0
- package/dist/types/ticketable/api/tickets.d.ts +16 -85
- package/dist/types/ticketable/components/ticketable-list/ticketable-list.d.ts +2 -12
- package/package.json +5 -1
- package/dist/cjs/auth-NU3DBc-6.js +0 -581
- package/dist/cjs/auth-NU3DBc-6.js.map +0 -1
- package/dist/cjs/auth-store-BaxuIp4z.js.map +0 -1
- package/dist/cjs/index-R2MKLaem.js.map +0 -1
- package/dist/cjs/newsletter-helpers-DR0vsegt.js.map +0 -1
- package/dist/collection/ticketable/api/get-with-schema.js +0 -35
- package/dist/collection/ticketable/api/get-with-schema.js.map +0 -1
- package/dist/components/auth.js +0 -580
- package/dist/components/auth.js.map +0 -1
- package/dist/esm/auth-nsjRdpvS.js +0 -579
- package/dist/esm/auth-nsjRdpvS.js.map +0 -1
- package/dist/esm/auth-store-CVvBlKGv.js.map +0 -1
- package/dist/esm/index-DSDkaHWI.js.map +0 -1
- package/dist/esm/newsletter-helpers-Dc_24im3.js.map +0 -1
- package/dist/sdk/p-0ab98e7a.entry.js +0 -2
- package/dist/sdk/p-0ab98e7a.entry.js.map +0 -1
- package/dist/sdk/p-0d324822.entry.js +0 -2
- package/dist/sdk/p-0d324822.entry.js.map +0 -1
- package/dist/sdk/p-0fb37ee9.entry.js +0 -2
- package/dist/sdk/p-0fb37ee9.entry.js.map +0 -1
- package/dist/sdk/p-3049e73f.entry.js +0 -2
- package/dist/sdk/p-3049e73f.entry.js.map +0 -1
- package/dist/sdk/p-312b919e.entry.js +0 -2
- package/dist/sdk/p-312b919e.entry.js.map +0 -1
- package/dist/sdk/p-319c5d3b.entry.js +0 -2
- package/dist/sdk/p-319c5d3b.entry.js.map +0 -1
- package/dist/sdk/p-34b98f55.entry.js +0 -2
- package/dist/sdk/p-34b98f55.entry.js.map +0 -1
- package/dist/sdk/p-4ec3302d.entry.js +0 -2
- package/dist/sdk/p-4ec3302d.entry.js.map +0 -1
- package/dist/sdk/p-568eabbc.entry.js +0 -2
- package/dist/sdk/p-568eabbc.entry.js.map +0 -1
- package/dist/sdk/p-5b40a68b.entry.js +0 -2
- package/dist/sdk/p-5b40a68b.entry.js.map +0 -1
- package/dist/sdk/p-66587fdd.entry.js +0 -2
- package/dist/sdk/p-66587fdd.entry.js.map +0 -1
- package/dist/sdk/p-88d93d64.entry.js +0 -2
- package/dist/sdk/p-90e2253e.entry.js +0 -2
- package/dist/sdk/p-90e2253e.entry.js.map +0 -1
- package/dist/sdk/p-BiILQPdb.js +0 -2
- package/dist/sdk/p-BiILQPdb.js.map +0 -1
- package/dist/sdk/p-DdUvQelg.js +0 -2
- package/dist/sdk/p-DdUvQelg.js.map +0 -1
- package/dist/sdk/p-PKvQIsOt.js +0 -2
- package/dist/sdk/p-PKvQIsOt.js.map +0 -1
- package/dist/sdk/p-a4f5940f.entry.js +0 -2
- package/dist/sdk/p-a4f5940f.entry.js.map +0 -1
- package/dist/sdk/p-aMrLKr2m.js +0 -2
- package/dist/sdk/p-aMrLKr2m.js.map +0 -1
- package/dist/sdk/p-bfb04b17.entry.js +0 -2
- package/dist/sdk/p-bfb04b17.entry.js.map +0 -1
- package/dist/sdk/p-c6816542.entry.js +0 -2
- package/dist/sdk/p-c6816542.entry.js.map +0 -1
- package/dist/sdk/p-da363474.entry.js +0 -2
- package/dist/sdk/p-da363474.entry.js.map +0 -1
- package/dist/sdk/p-e54d5d38.entry.js +0 -2
- package/dist/sdk/p-e54d5d38.entry.js.map +0 -1
- package/dist/sdk/p-e81bbd62.entry.js +0 -2
- package/dist/sdk/p-e81bbd62.entry.js.map +0 -1
- package/dist/sdk/p-effaf86b.entry.js +0 -2
- package/dist/types/ticketable/api/get-with-schema.d.ts +0 -3
- /package/dist/sdk/{p-5babee6b.entry.js.map → p-098eef67.entry.js.map} +0 -0
- /package/dist/sdk/{p-e2e7061b.entry.js.map → p-5da49d00.entry.js.map} +0 -0
- /package/dist/sdk/{p-88d93d64.entry.js.map → p-745742f1.entry.js.map} +0 -0
- /package/dist/sdk/{p-9e71a36c.entry.js.map → p-74e6523f.entry.js.map} +0 -0
- /package/dist/sdk/{p-39b61f33.entry.js.map → p-bbbec3d4.entry.js.map} +0 -0
- /package/dist/sdk/{p-f232929b.entry.js.map → p-c2fba7c8.entry.js.map} +0 -0
- /package/dist/sdk/{p-a69b83ec.entry.js.map → p-e0d2397c.entry.js.map} +0 -0
- /package/dist/sdk/{p-80034205.entry.js.map → p-e6beb9d7.entry.js.map} +0 -0
- /package/dist/sdk/{p-2cb6a2d0.entry.js.map → p-f1788e52.entry.js.map} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { g as getUnidyClient } from './index2.js';
|
|
2
|
-
import { A as Auth } from './auth.js';
|
|
3
2
|
import { t } from './i18n.js';
|
|
4
3
|
import { c as createLogger } from './logger.js';
|
|
5
4
|
import { F as Flash } from './flash-store.js';
|
|
@@ -15,16 +14,15 @@ function newsletterLogout() {
|
|
|
15
14
|
}
|
|
16
15
|
async function resendDoi(internalName) {
|
|
17
16
|
const { preferenceToken } = newsletterStore.state;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
idToken: typeof idToken === "string" ? idToken : "",
|
|
17
|
+
const [error] = await getUnidyClient().newsletters.resendDoi({
|
|
18
|
+
internalName,
|
|
19
|
+
payload: { redirect_to_after_confirmation: redirectToAfterConfirmationUrl() },
|
|
20
|
+
options: { preferenceToken },
|
|
23
21
|
});
|
|
24
|
-
if (
|
|
22
|
+
if (error === null) {
|
|
25
23
|
return true;
|
|
26
24
|
}
|
|
27
|
-
if (
|
|
25
|
+
if (error === "unauthorized") {
|
|
28
26
|
Flash.error.addMessage(t("newsletter.errors.unauthorized"));
|
|
29
27
|
newsletterLogout();
|
|
30
28
|
return false;
|
|
@@ -32,15 +30,17 @@ async function resendDoi(internalName) {
|
|
|
32
30
|
return false;
|
|
33
31
|
}
|
|
34
32
|
async function sendLoginEmail(email) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const [error] = await getUnidyClient().newsletters.sendLoginEmail({
|
|
34
|
+
payload: {
|
|
35
|
+
email,
|
|
36
|
+
redirect_uri: redirectToAfterConfirmationUrl(),
|
|
37
|
+
},
|
|
38
38
|
});
|
|
39
|
-
if (
|
|
39
|
+
if (error === null) {
|
|
40
40
|
Flash.info.addMessage(t("newsletter.success.login_email_sent"));
|
|
41
41
|
}
|
|
42
|
-
else if (
|
|
43
|
-
Flash.error.addMessage(t("newsletter.errors.
|
|
42
|
+
else if (error === "rate_limit_exceeded") {
|
|
43
|
+
Flash.error.addMessage(t("newsletter.errors.rate_limit_exceeded", { defaultValue: "Too many requests. Please try again later." }));
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
Flash.error.addMessage(t("errors.unknown", { defaultValue: "An unknown error occurred" }));
|
|
@@ -53,28 +53,25 @@ async function fetchSubscriptions() {
|
|
|
53
53
|
logger.error("Preference token or authentication is required to fetch subscriptions");
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
const authInstance = await Auth.getInstance();
|
|
57
|
-
const idToken = await authInstance.getToken();
|
|
58
56
|
newsletterStore.state.fetchingSubscriptions = true;
|
|
59
|
-
const
|
|
60
|
-
preferenceToken,
|
|
61
|
-
idToken: typeof idToken === "string" ? idToken : "",
|
|
57
|
+
const [error, data] = await getUnidyClient().newsletters.list({
|
|
58
|
+
options: { preferenceToken },
|
|
62
59
|
});
|
|
63
60
|
newsletterStore.state.fetchingSubscriptions = false;
|
|
64
|
-
if (
|
|
61
|
+
if (error === "unauthorized") {
|
|
65
62
|
newsletterLogout();
|
|
66
63
|
Flash.error.addMessage(t("newsletter.errors.unauthorized"));
|
|
67
64
|
return;
|
|
68
65
|
}
|
|
69
|
-
if (
|
|
70
|
-
newsletterStore.state.existingSubscriptions =
|
|
66
|
+
if (error === null && data && Array.isArray(data)) {
|
|
67
|
+
newsletterStore.state.existingSubscriptions = data.map((sub) => ({
|
|
71
68
|
newsletter_internal_name: sub.newsletter_internal_name,
|
|
72
69
|
confirmed: sub.confirmed_at !== null,
|
|
73
70
|
preference_identifiers: sub.preference_identifiers || [],
|
|
74
71
|
}));
|
|
75
72
|
// init checked newsletters and preferences
|
|
76
73
|
const checkedNewsletters = { ...newsletterStore.state.checkedNewsletters };
|
|
77
|
-
for (const sub of
|
|
74
|
+
for (const sub of data) {
|
|
78
75
|
checkedNewsletters[sub.newsletter_internal_name] = [...(sub.preference_identifiers || [])];
|
|
79
76
|
}
|
|
80
77
|
newsletterStore.state.checkedNewsletters = checkedNewsletters;
|
|
@@ -87,7 +84,7 @@ async function handleAlreadySubscribedError(email, errors) {
|
|
|
87
84
|
.filter((err) => err.error_identifier === "already_subscribed" && !existingNames.has(err.meta.newsletter_internal_name))
|
|
88
85
|
.map((err) => ({
|
|
89
86
|
newsletter_internal_name: err.meta.newsletter_internal_name,
|
|
90
|
-
confirmed:
|
|
87
|
+
confirmed: false, // We don't know the confirmation status for already_subscribed errors
|
|
91
88
|
preference_identifiers: [],
|
|
92
89
|
}));
|
|
93
90
|
if (newSubscriptions.length > 0) {
|
|
@@ -99,22 +96,20 @@ async function handleAlreadySubscribedError(email, errors) {
|
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
async function handleCreateSubscriptionRequest(email, internalNames, showSuccessMessage = true) {
|
|
102
|
-
const authInstance = await Auth.getInstance();
|
|
103
|
-
const idToken = await authInstance.getToken();
|
|
104
99
|
const { checkedNewsletters } = newsletterStore.state;
|
|
105
|
-
const [error, response] = await getUnidyClient().newsletters.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
const [error, response] = await getUnidyClient().newsletters.create({
|
|
101
|
+
payload: {
|
|
102
|
+
email,
|
|
103
|
+
newsletter_subscriptions: internalNames.map((newsletter) => ({
|
|
104
|
+
newsletter_internal_name: newsletter,
|
|
105
|
+
preference_identifiers: checkedNewsletters[newsletter] || [],
|
|
106
|
+
})),
|
|
107
|
+
redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),
|
|
108
|
+
},
|
|
114
109
|
});
|
|
115
|
-
if (error === null) {
|
|
116
|
-
if (response.
|
|
117
|
-
const newSubscriptions = response.
|
|
110
|
+
if (error === null && response && "results" in response) {
|
|
111
|
+
if (response.results.length > 0) {
|
|
112
|
+
const newSubscriptions = response.results.map((result) => ({
|
|
118
113
|
newsletter_internal_name: result.newsletter_internal_name,
|
|
119
114
|
confirmed: result.confirmed_at !== null,
|
|
120
115
|
preference_identifiers: result.preference_identifiers || [],
|
|
@@ -131,8 +126,8 @@ async function handleCreateSubscriptionRequest(email, internalNames, showSuccess
|
|
|
131
126
|
newsletterLogout();
|
|
132
127
|
return false;
|
|
133
128
|
}
|
|
134
|
-
if (error === "newsletter_error") {
|
|
135
|
-
const errors = response.
|
|
129
|
+
if (error === "newsletter_error" && response) {
|
|
130
|
+
const errors = response.errors || [];
|
|
136
131
|
const errorMap = {};
|
|
137
132
|
// special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the
|
|
138
133
|
// already_subscribed subscriptions to the existing subscriptions
|
|
@@ -174,38 +169,31 @@ async function deleteSubscription(internalName) {
|
|
|
174
169
|
logger.error("Preference token or authentication is required to delete a subscription");
|
|
175
170
|
return false;
|
|
176
171
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
preferenceToken,
|
|
181
|
-
idToken: typeof idToken === "string" ? idToken : "",
|
|
172
|
+
const [error, data] = await getUnidyClient().newsletters.delete({
|
|
173
|
+
internalName,
|
|
174
|
+
options: { preferenceToken },
|
|
182
175
|
});
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
newsletterStore.state.
|
|
187
|
-
|
|
176
|
+
if (error === null) {
|
|
177
|
+
if (data && "new_preference_token" in data) {
|
|
178
|
+
// if user is not authenticated, we need to store the new preference token which is used for the next request
|
|
179
|
+
if (!newsletterStore.state.isAuthenticated) {
|
|
180
|
+
newsletterStore.state.preferenceToken = data.new_preference_token;
|
|
181
|
+
persist("preferenceToken");
|
|
182
|
+
}
|
|
183
|
+
newsletterStore.state.existingSubscriptions = newsletterStore.state.existingSubscriptions.filter((sub) => sub.newsletter_internal_name !== internalName);
|
|
184
|
+
return true;
|
|
188
185
|
}
|
|
189
|
-
|
|
190
|
-
// Reset checked preferences to defaults (preferences marked with checked='true')
|
|
191
|
-
const defaultPrefs = newsletterStore.state.defaultPreferences[internalName];
|
|
192
|
-
newsletterStore.state.checkedNewsletters = {
|
|
193
|
-
...newsletterStore.state.checkedNewsletters,
|
|
194
|
-
[internalName]: defaultPrefs ? [...defaultPrefs] : [],
|
|
195
|
-
};
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
if (response.status === 204) {
|
|
186
|
+
// data is null - last subscription was deleted
|
|
199
187
|
newsletterLogout();
|
|
200
188
|
newsletterStore.state.checkedNewsletters = {};
|
|
201
189
|
return true;
|
|
202
190
|
}
|
|
203
|
-
if (
|
|
191
|
+
if (error === "unauthorized") {
|
|
204
192
|
Flash.error.addMessage(t("newsletter.errors.unauthorized"));
|
|
205
193
|
newsletterLogout();
|
|
206
194
|
return false;
|
|
207
195
|
}
|
|
208
|
-
if (
|
|
196
|
+
if (error === "not_found") {
|
|
209
197
|
return false;
|
|
210
198
|
}
|
|
211
199
|
Flash.error.addMessage(t("errors.unknown", { defaultValue: "An unknown error occurred" }));
|
|
@@ -242,26 +230,25 @@ async function updateSubscriptionPreferences(internalName) {
|
|
|
242
230
|
logger.error(`Cannot update preferences: not subscribed to newsletter '${internalName}'`);
|
|
243
231
|
return false;
|
|
244
232
|
}
|
|
245
|
-
const authInstance = await Auth.getInstance();
|
|
246
|
-
const idToken = await authInstance.getToken();
|
|
247
233
|
const preferenceIdentifiers = newsletterStore.state.checkedNewsletters[internalName] || [];
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
234
|
+
const [error, data] = await getUnidyClient().newsletters.update({
|
|
235
|
+
internalName,
|
|
236
|
+
payload: { preference_identifiers: preferenceIdentifiers },
|
|
237
|
+
options: { preferenceToken },
|
|
251
238
|
});
|
|
252
|
-
if (
|
|
239
|
+
if (error === "unauthorized") {
|
|
253
240
|
Flash.error.addMessage(t("newsletter.errors.unauthorized"));
|
|
254
241
|
newsletterLogout();
|
|
255
242
|
return false;
|
|
256
243
|
}
|
|
257
|
-
if (
|
|
244
|
+
if (error === null && data && "preference_identifiers" in data) {
|
|
258
245
|
// Update the local subscription with the new preferences
|
|
259
246
|
const subscriptionIndex = newsletterStore.state.existingSubscriptions.findIndex((sub) => sub.newsletter_internal_name === internalName);
|
|
260
247
|
if (subscriptionIndex !== -1) {
|
|
261
248
|
const updatedSubscriptions = [...newsletterStore.state.existingSubscriptions];
|
|
262
249
|
updatedSubscriptions[subscriptionIndex] = {
|
|
263
250
|
...updatedSubscriptions[subscriptionIndex],
|
|
264
|
-
preference_identifiers:
|
|
251
|
+
preference_identifiers: data.preference_identifiers || [],
|
|
265
252
|
};
|
|
266
253
|
newsletterStore.state.existingSubscriptions = updatedSubscriptions;
|
|
267
254
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"newsletter-helpers.js","mappings":";;;;;;;AAaA,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,mBAAmB;SAE9B,gBAAgB,GAAA;AAC9B,IAAA,eAAe,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE;AAC1C,IAAA,eAAe,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE;AAChD,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,eAAA,CAAiB,CAAC;AACjE,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,KAAA,CAAO,CAAC;AACzD;AAEO,eAAe,SAAS,CAAC,YAAoB,EAAA;AAClD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,KAAK;AAEjD,IAAA,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE;AAC7C,IAAA,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE;AAE7C,IAAA,MAAM,QAAQ,GAAG,MAAM,cAAc,EAAE,CAAC,WAAW,CAAC,SAAS,CAC3D,YAAY,EACZ,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,EAAE,EACpE;AACE,QAAA,eAAe,EAAE,OAAO,eAAe,KAAK,QAAQ,GAAG,eAAe,GAAG,EAAE;AAC3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} from \"../api\";\nimport { Auth } from \"../auth/auth\";\nimport { t } from \"../i18n\";\nimport { createLogger } from \"../logger\";\nimport { Flash } from \"../shared/store/flash-store\";\nimport {\n type CheckedNewsletters,\n type ExistingSubscription,\n type NewsletterErrorIdentifier,\n newsletterStore,\n persist,\n} from \"./store/newsletter-store\";\n\nconst logger = createLogger(\"NewsletterHelpers\");\n\nconst PERSIST_KEY_PREFIX = \"unidy_newsletter_\";\n\nexport function newsletterLogout(): void {\n newsletterStore.state.preferenceToken = \"\";\n newsletterStore.state.existingSubscriptions = [];\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}preferenceToken`);\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}email`);\n}\n\nexport async function resendDoi(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n const authInstance = await Auth.getInstance();\n const idToken = await authInstance.getToken();\n\n const response = await getUnidyClient().newsletters.resendDoi(\n internalName,\n { redirect_to_after_confirmation: redirectToAfterConfirmationUrl() },\n {\n preferenceToken: typeof preferenceToken === \"string\" ? preferenceToken : \"\",\n idToken: typeof idToken === \"string\" ? idToken : \"\",\n },\n );\n\n if (response.status === 204) {\n return true;\n }\n\n if (response.status === 401) {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n return false;\n}\n\nexport async function sendLoginEmail(email: string): Promise<void> {\n const response = await getUnidyClient().newsletters.sendLoginEmail({\n email,\n redirect_uri: redirectToAfterConfirmationUrl(),\n });\n\n if (response.status === 204) {\n Flash.info.addMessage(t(\"newsletter.success.login_email_sent\"));\n } else if (response.status === 404) {\n Flash.error.addMessage(t(\"newsletter.errors.login_email_not_found\"));\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n}\n\nexport async function fetchSubscriptions(): Promise<void> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to fetch subscriptions\");\n return;\n }\n\n const authInstance = await Auth.getInstance();\n const idToken = await authInstance.getToken();\n\n newsletterStore.state.fetchingSubscriptions = true;\n\n const response = await getUnidyClient().newsletters.listSubscriptions({\n preferenceToken,\n idToken: typeof idToken === \"string\" ? idToken : \"\",\n });\n\n newsletterStore.state.fetchingSubscriptions = false;\n\n if (response.status === 401) {\n newsletterLogout();\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n return;\n }\n\n if (response.success && response.data) {\n newsletterStore.state.existingSubscriptions = response.data.map(\n (sub): ExistingSubscription => ({\n newsletter_internal_name: sub.newsletter_internal_name,\n confirmed: sub.confirmed_at !== null,\n preference_identifiers: sub.preference_identifiers || [],\n }),\n );\n\n // init checked newsletters and preferences\n const checkedNewsletters: CheckedNewsletters = { ...newsletterStore.state.checkedNewsletters };\n for (const sub of response.data) {\n checkedNewsletters[sub.newsletter_internal_name] = [...(sub.preference_identifiers || [])];\n }\n newsletterStore.state.checkedNewsletters = checkedNewsletters;\n }\n}\n\nasync function handleAlreadySubscribedError(\n email: string,\n errors: Array<{ error_identifier: string; meta: { newsletter_internal_name: string } }>,\n): Promise<void> {\n if (newsletterStore.state.isAuthenticated || newsletterStore.state.preferenceToken) {\n const existingNames = new Set(newsletterStore.state.existingSubscriptions.map((s) => s.newsletter_internal_name));\n\n const newSubscriptions: ExistingSubscription[] = errors\n .filter((err) => err.error_identifier === \"already_subscribed\" && !existingNames.has(err.meta.newsletter_internal_name))\n .map((err) => ({\n newsletter_internal_name: err.meta.newsletter_internal_name,\n confirmed: null,\n preference_identifiers: [],\n }));\n\n if (newSubscriptions.length > 0) {\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n } else {\n await sendLoginEmail(email);\n }\n}\n\nasync function handleCreateSubscriptionRequest(email: string, internalNames: string[], showSuccessMessage = true): Promise<boolean> {\n const authInstance = await Auth.getInstance();\n const idToken = await authInstance.getToken();\n const { checkedNewsletters } = newsletterStore.state;\n\n const [error, response] = await getUnidyClient().newsletters.createSubscriptions(\n {\n email,\n newsletter_subscriptions: internalNames.map((newsletter) => ({\n newsletter_internal_name: newsletter,\n preference_identifiers: checkedNewsletters[newsletter] || [],\n })),\n redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),\n },\n {\n idToken: typeof idToken === \"string\" ? idToken : \"\",\n },\n );\n\n if (error === null) {\n if (response.data?.results && response.data.results.length > 0) {\n const newSubscriptions: ExistingSubscription[] = response.data.results.map((result) => ({\n newsletter_internal_name: result.newsletter_internal_name,\n confirmed: result.confirmed_at !== null,\n preference_identifiers: result.preference_identifiers || [],\n }));\n\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n\n if (showSuccessMessage) {\n Flash.success.addMessage(t(\"newsletter.success.subscribe\"));\n }\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"newsletter_error\") {\n const errors = response.data?.errors || [];\n const errorMap: Record<string, NewsletterErrorIdentifier> = {};\n\n // special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the\n // already_subscribed subscriptions to the existing subscriptions\n const hasAlreadySubscribedError = errors.some((err) => err.error_identifier === \"already_subscribed\");\n if (hasAlreadySubscribedError) {\n await handleAlreadySubscribedError(email, errors);\n }\n\n const newsletterNotFoundError = errors.some((err) => err.error_identifier === \"newsletter_not_found\");\n if (newsletterNotFoundError) {\n errorMap.general = \"newsletter_not_found\";\n }\n\n const hasInvalidEmailError = errors.some(\n (err) => err.error_identifier === \"validation_error\" && err.error_details && \"email\" in err.error_details,\n );\n\n if (hasInvalidEmailError) {\n errorMap.email = \"invalid_email\";\n } else {\n for (const err of errors) {\n errorMap[err.meta.newsletter_internal_name] = err.error_identifier as NewsletterErrorIdentifier;\n }\n }\n\n newsletterStore.state.errors = errorMap;\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n\n return false;\n}\n\nexport async function subscribeToNewsletter(internalName: string, email: string): Promise<boolean> {\n return handleCreateSubscriptionRequest(email, [internalName], false);\n}\n\nexport async function createSubscriptions({ email }: { email: string }): Promise<void> {\n const internalNames = Object.keys(newsletterStore.state.checkedNewsletters);\n await handleCreateSubscriptionRequest(email, internalNames, true);\n}\n\nexport async function deleteSubscription(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated to delete a subscription\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to delete a subscription\");\n return false;\n }\n\n const authInstance = await Auth.getInstance();\n const idToken = await authInstance.getToken();\n\n const response = await getUnidyClient().newsletters.deleteSubscription(internalName, {\n preferenceToken,\n idToken: typeof idToken === \"string\" ? idToken : \"\",\n });\n\n if (response.status === 200 && response.data?.new_preference_token) {\n // if user is not authenticated, we need to store the new preference token which is used for the next request\n if (!newsletterStore.state.isAuthenticated) {\n newsletterStore.state.preferenceToken = response.data.new_preference_token;\n persist(\"preferenceToken\");\n }\n\n newsletterStore.state.existingSubscriptions = newsletterStore.state.existingSubscriptions.filter(\n (sub) => sub.newsletter_internal_name !== internalName,\n );\n\n // Reset checked preferences to defaults (preferences marked with checked='true')\n const defaultPrefs = newsletterStore.state.defaultPreferences[internalName];\n newsletterStore.state.checkedNewsletters = {\n ...newsletterStore.state.checkedNewsletters,\n [internalName]: defaultPrefs ? [...defaultPrefs] : [],\n };\n\n return true;\n }\n\n if (response.status === 204) {\n newsletterLogout();\n\n newsletterStore.state.checkedNewsletters = {};\n return true;\n }\n\n if (response.status === 401) {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (response.status === 422) {\n return false;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n\nexport function getSubscription(internalName: string): ExistingSubscription | undefined {\n return newsletterStore.state.existingSubscriptions.find((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isSubscribed(internalName: string): boolean {\n return newsletterStore.state.existingSubscriptions.some((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isConfirmed(internalName: string): boolean {\n const sub = getSubscription(internalName);\n return sub?.confirmed ?? false;\n}\n\nfunction redirectToAfterConfirmationUrl(): string {\n const baseUrl = `${location.origin}${location.pathname}`;\n const params = new URLSearchParams(location.search);\n for (const key of [\"email\", \"newsletter_error\"]) {\n params.delete(key);\n }\n const queryString = params.toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n}\n\nexport function getSubscriptionPreferences(internalName: string): string[] {\n const subscription = getSubscription(internalName);\n return subscription?.preference_identifiers || [];\n}\n\nexport async function updateSubscriptionPreferences(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // Either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to update subscription preferences\");\n return false;\n }\n\n // Check if the subscription exists\n if (!isSubscribed(internalName)) {\n logger.error(`Cannot update preferences: not subscribed to newsletter '${internalName}'`);\n return false;\n }\n\n const authInstance = await Auth.getInstance();\n const idToken = await authInstance.getToken();\n\n const preferenceIdentifiers = newsletterStore.state.checkedNewsletters[internalName] || [];\n\n const response = await getUnidyClient().newsletters.updateSubscription(\n internalName,\n { preference_identifiers: preferenceIdentifiers },\n {\n preferenceToken,\n idToken: typeof idToken === \"string\" ? idToken : \"\",\n },\n );\n\n if (response.status === 401) {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (response.success && response.data) {\n // Update the local subscription with the new preferences\n const subscriptionIndex = newsletterStore.state.existingSubscriptions.findIndex((sub) => sub.newsletter_internal_name === internalName);\n\n if (subscriptionIndex !== -1) {\n const updatedSubscriptions = [...newsletterStore.state.existingSubscriptions];\n updatedSubscriptions[subscriptionIndex] = {\n ...updatedSubscriptions[subscriptionIndex],\n preference_identifiers: response.data.preference_identifiers || [],\n };\n newsletterStore.state.existingSubscriptions = updatedSubscriptions;\n }\n\n Flash.success.addMessage(t(\"newsletter.success.preferences_updated\"));\n return true;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n"],"version":3}
|
|
1
|
+
{"file":"newsletter-helpers.js","mappings":";;;;;;AAYA,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,mBAAmB;SAE9B,gBAAgB,GAAA;AAC9B,IAAA,eAAe,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE;AAC1C,IAAA,eAAe,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE;AAChD,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,eAAA,CAAiB,CAAC;AACjE,IAAA,cAAc,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAA,KAAA,CAAO,CAAC;AACzD;AAEO,eAAe,SAAS,CAAC,YAAoB,EAAA;AAClD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,KAAK;IAEjD,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,cAAc,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;QAC3D,YAAY;AACZ,QAAA,OAAO,EAAE,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,EAAE;QAC7E,OAAO,EAAE,EAAE,eAAe,EAAE;AAC7B,KAAA,CAAC;AAEF,IAAA,IAAI,KAAK,KAAK,IAAI,EAAE;AAClB,QAAA,OAAO,IAAI;;AAGb,IAAA,IAAI,KAAK,KAAK,cAAc,EAAE;QAC5B,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC;AAC3D,QAAA,gBAAgB,EAAE;A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"../i18n\";\nimport { createLogger } from \"../logger\";\nimport { Flash } from \"../shared/store/flash-store\";\nimport {\n type CheckedNewsletters,\n type ExistingSubscription,\n type NewsletterErrorIdentifier,\n newsletterStore,\n persist,\n} from \"./store/newsletter-store\";\n\nconst logger = createLogger(\"NewsletterHelpers\");\n\nconst PERSIST_KEY_PREFIX = \"unidy_newsletter_\";\n\nexport function newsletterLogout(): void {\n newsletterStore.state.preferenceToken = \"\";\n newsletterStore.state.existingSubscriptions = [];\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}preferenceToken`);\n sessionStorage.removeItem(`${PERSIST_KEY_PREFIX}email`);\n}\n\nexport async function resendDoi(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n const [error] = await getUnidyClient().newsletters.resendDoi({\n internalName,\n payload: { redirect_to_after_confirmation: redirectToAfterConfirmationUrl() },\n options: { preferenceToken },\n });\n\n if (error === null) {\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n return false;\n}\n\nexport async function sendLoginEmail(email: string): Promise<void> {\n const [error] = await getUnidyClient().newsletters.sendLoginEmail({\n payload: {\n email,\n redirect_uri: redirectToAfterConfirmationUrl(),\n },\n });\n\n if (error === null) {\n Flash.info.addMessage(t(\"newsletter.success.login_email_sent\"));\n } else if (error === \"rate_limit_exceeded\") {\n Flash.error.addMessage(t(\"newsletter.errors.rate_limit_exceeded\", { defaultValue: \"Too many requests. Please try again later.\" }));\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n}\n\nexport async function fetchSubscriptions(): Promise<void> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to fetch subscriptions\");\n return;\n }\n\n newsletterStore.state.fetchingSubscriptions = true;\n\n const [error, data] = await getUnidyClient().newsletters.list({\n options: { preferenceToken },\n });\n\n newsletterStore.state.fetchingSubscriptions = false;\n\n if (error === \"unauthorized\") {\n newsletterLogout();\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n return;\n }\n\n if (error === null && data && Array.isArray(data)) {\n newsletterStore.state.existingSubscriptions = data.map(\n (sub): ExistingSubscription => ({\n newsletter_internal_name: sub.newsletter_internal_name,\n confirmed: sub.confirmed_at !== null,\n preference_identifiers: sub.preference_identifiers || [],\n }),\n );\n\n // init checked newsletters and preferences\n const checkedNewsletters: CheckedNewsletters = { ...newsletterStore.state.checkedNewsletters };\n for (const sub of data) {\n checkedNewsletters[sub.newsletter_internal_name] = [...(sub.preference_identifiers || [])];\n }\n newsletterStore.state.checkedNewsletters = checkedNewsletters;\n }\n}\n\nasync function handleAlreadySubscribedError(\n email: string,\n errors: Array<{ error_identifier: string; meta: { newsletter_internal_name: string } }>,\n): Promise<void> {\n if (newsletterStore.state.isAuthenticated || newsletterStore.state.preferenceToken) {\n const existingNames = new Set(newsletterStore.state.existingSubscriptions.map((s) => s.newsletter_internal_name));\n\n const newSubscriptions: ExistingSubscription[] = errors\n .filter((err) => err.error_identifier === \"already_subscribed\" && !existingNames.has(err.meta.newsletter_internal_name))\n .map((err) => ({\n newsletter_internal_name: err.meta.newsletter_internal_name,\n confirmed: false, // We don't know the confirmation status for already_subscribed errors\n preference_identifiers: [],\n }));\n\n if (newSubscriptions.length > 0) {\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n } else {\n await sendLoginEmail(email);\n }\n}\n\nasync function handleCreateSubscriptionRequest(email: string, internalNames: string[], showSuccessMessage = true): Promise<boolean> {\n const { checkedNewsletters } = newsletterStore.state;\n\n const [error, response] = await getUnidyClient().newsletters.create({\n payload: {\n email,\n newsletter_subscriptions: internalNames.map((newsletter) => ({\n newsletter_internal_name: newsletter,\n preference_identifiers: checkedNewsletters[newsletter] || [],\n })),\n redirect_to_after_confirmation: redirectToAfterConfirmationUrl(),\n },\n });\n\n if (error === null && response && \"results\" in response) {\n if (response.results.length > 0) {\n const newSubscriptions: ExistingSubscription[] = response.results.map((result) => ({\n newsletter_internal_name: result.newsletter_internal_name,\n confirmed: result.confirmed_at !== null,\n preference_identifiers: result.preference_identifiers || [],\n }));\n\n newsletterStore.state.existingSubscriptions = [...newsletterStore.state.existingSubscriptions, ...newSubscriptions];\n }\n\n if (showSuccessMessage) {\n Flash.success.addMessage(t(\"newsletter.success.subscribe\"));\n }\n\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"newsletter_error\" && response) {\n const errors = response.errors || [];\n const errorMap: Record<string, NewsletterErrorIdentifier> = {};\n\n // special error case which is handled differently: if user is not authenticated, we send a login email, otherwise we add the\n // already_subscribed subscriptions to the existing subscriptions\n const hasAlreadySubscribedError = errors.some((err) => err.error_identifier === \"already_subscribed\");\n if (hasAlreadySubscribedError) {\n await handleAlreadySubscribedError(email, errors);\n }\n\n const newsletterNotFoundError = errors.some((err) => err.error_identifier === \"newsletter_not_found\");\n if (newsletterNotFoundError) {\n errorMap.general = \"newsletter_not_found\";\n }\n\n const hasInvalidEmailError = errors.some(\n (err) => err.error_identifier === \"validation_error\" && err.error_details && \"email\" in err.error_details,\n );\n\n if (hasInvalidEmailError) {\n errorMap.email = \"invalid_email\";\n } else {\n for (const err of errors) {\n errorMap[err.meta.newsletter_internal_name] = err.error_identifier as NewsletterErrorIdentifier;\n }\n }\n\n newsletterStore.state.errors = errorMap;\n } else {\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n }\n\n return false;\n}\n\nexport async function subscribeToNewsletter(internalName: string, email: string): Promise<boolean> {\n return handleCreateSubscriptionRequest(email, [internalName], false);\n}\n\nexport async function createSubscriptions({ email }: { email: string }): Promise<void> {\n const internalNames = Object.keys(newsletterStore.state.checkedNewsletters);\n await handleCreateSubscriptionRequest(email, internalNames, true);\n}\n\nexport async function deleteSubscription(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // either preference token is needed or the user must be authenticated to delete a subscription\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to delete a subscription\");\n return false;\n }\n\n const [error, data] = await getUnidyClient().newsletters.delete({\n internalName,\n options: { preferenceToken },\n });\n\n if (error === null) {\n if (data && \"new_preference_token\" in data) {\n // if user is not authenticated, we need to store the new preference token which is used for the next request\n if (!newsletterStore.state.isAuthenticated) {\n newsletterStore.state.preferenceToken = data.new_preference_token;\n persist(\"preferenceToken\");\n }\n\n newsletterStore.state.existingSubscriptions = newsletterStore.state.existingSubscriptions.filter(\n (sub) => sub.newsletter_internal_name !== internalName,\n );\n return true;\n }\n\n // data is null - last subscription was deleted\n newsletterLogout();\n newsletterStore.state.checkedNewsletters = {};\n return true;\n }\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === \"not_found\") {\n return false;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n\nexport function getSubscription(internalName: string): ExistingSubscription | undefined {\n return newsletterStore.state.existingSubscriptions.find((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isSubscribed(internalName: string): boolean {\n return newsletterStore.state.existingSubscriptions.some((sub) => sub.newsletter_internal_name === internalName);\n}\n\nexport function isConfirmed(internalName: string): boolean {\n const sub = getSubscription(internalName);\n return sub?.confirmed ?? false;\n}\n\nfunction redirectToAfterConfirmationUrl(): string {\n const baseUrl = `${location.origin}${location.pathname}`;\n const params = new URLSearchParams(location.search);\n for (const key of [\"email\", \"newsletter_error\"]) {\n params.delete(key);\n }\n const queryString = params.toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n}\n\nexport function getSubscriptionPreferences(internalName: string): string[] {\n const subscription = getSubscription(internalName);\n return subscription?.preference_identifiers || [];\n}\n\nexport async function updateSubscriptionPreferences(internalName: string): Promise<boolean> {\n const { preferenceToken } = newsletterStore.state;\n\n // Either preference token is needed or the user must be authenticated\n if (!preferenceToken && !newsletterStore.state.isAuthenticated) {\n logger.error(\"Preference token or authentication is required to update subscription preferences\");\n return false;\n }\n\n // Check if the subscription exists\n if (!isSubscribed(internalName)) {\n logger.error(`Cannot update preferences: not subscribed to newsletter '${internalName}'`);\n return false;\n }\n\n const preferenceIdentifiers = newsletterStore.state.checkedNewsletters[internalName] || [];\n\n const [error, data] = await getUnidyClient().newsletters.update({\n internalName,\n payload: { preference_identifiers: preferenceIdentifiers },\n options: { preferenceToken },\n });\n\n if (error === \"unauthorized\") {\n Flash.error.addMessage(t(\"newsletter.errors.unauthorized\"));\n newsletterLogout();\n return false;\n }\n\n if (error === null && data && \"preference_identifiers\" in data) {\n // Update the local subscription with the new preferences\n const subscriptionIndex = newsletterStore.state.existingSubscriptions.findIndex((sub) => sub.newsletter_internal_name === internalName);\n\n if (subscriptionIndex !== -1) {\n const updatedSubscriptions = [...newsletterStore.state.existingSubscriptions];\n updatedSubscriptions[subscriptionIndex] = {\n ...updatedSubscriptions[subscriptionIndex],\n preference_identifiers: data.preference_identifiers || [],\n };\n newsletterStore.state.existingSubscriptions = updatedSubscriptions;\n }\n\n Flash.success.addMessage(t(\"newsletter.success.preferences_updated\"));\n return true;\n }\n\n Flash.error.addMessage(t(\"errors.unknown\", { defaultValue: \"An unknown error occurred\" }));\n return false;\n}\n"],"version":3}
|
|
@@ -1,73 +1,66 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement,
|
|
2
|
-
import { g as getUnidyClient } from './index2.js';
|
|
3
|
-
import { a as authStore, b as authStoreOnChange } from './auth-store.js';
|
|
4
|
-
import { A as Auth } from './auth.js';
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
5
2
|
import { t } from './i18n.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { b as authStoreOnChange, a as authStore } from './auth-store.js';
|
|
4
|
+
import { h as Auth, g as getUnidyClient } from './index2.js';
|
|
8
5
|
import { s as state, a as profileStoreOnChange } from './profile-store.js';
|
|
6
|
+
import { o as onChange } from './unidy-store.js';
|
|
7
|
+
import { v as validateRequiredFieldsUnchanged, b as buildPayload } from './profile-helpers.js';
|
|
9
8
|
import { Y as captureException } from './exports.js';
|
|
10
9
|
|
|
11
10
|
const Profile = /*@__PURE__*/ proxyCustomElement(class Profile extends HTMLElement {
|
|
12
11
|
profileId;
|
|
13
12
|
initialData = "";
|
|
14
|
-
uProfileSuccess;
|
|
15
|
-
uProfileError;
|
|
16
13
|
fetchingProfileData = false;
|
|
17
14
|
constructor(registerHost) {
|
|
18
15
|
super();
|
|
19
16
|
if (registerHost !== false) {
|
|
20
17
|
this.__registerHost();
|
|
21
18
|
}
|
|
22
|
-
this.uProfileSuccess = createEvent(this, "uProfileSuccess", 7);
|
|
23
|
-
this.uProfileError = createEvent(this, "uProfileError", 7);
|
|
24
19
|
onChange("locale", async (_locale) => {
|
|
25
|
-
|
|
26
|
-
await this.getTokenAndFetchProfile();
|
|
20
|
+
await this.fetchProfileData();
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
23
|
async componentWillLoad() {
|
|
30
24
|
if (this.initialData !== "") {
|
|
31
25
|
state.data = typeof this.initialData === "string" ? JSON.parse(this.initialData) : this.initialData;
|
|
32
26
|
}
|
|
33
|
-
else
|
|
34
|
-
await this.
|
|
27
|
+
else {
|
|
28
|
+
await this.fetchProfileData();
|
|
35
29
|
}
|
|
36
30
|
state.loading = false;
|
|
37
31
|
}
|
|
38
|
-
async
|
|
39
|
-
const authInstance = await Auth.getInstance();
|
|
40
|
-
const idToken = await authInstance.getToken();
|
|
41
|
-
if (idToken && typeof idToken === "string") {
|
|
42
|
-
await this.fetchProfileData(idToken);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async fetchProfileData(idToken) {
|
|
32
|
+
async fetchProfileData() {
|
|
46
33
|
// avoid multiple requests
|
|
47
34
|
if (this.fetchingProfileData)
|
|
48
35
|
return;
|
|
36
|
+
const authInstance = await Auth.getInstance();
|
|
37
|
+
const isAuthenticated = await authInstance.isAuthenticated();
|
|
38
|
+
if (!isAuthenticated) {
|
|
39
|
+
// Handle unauthenticated state the same as an unauthorized error from backend
|
|
40
|
+
state.flashErrors = { error: t("errors.unauthorized") };
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
49
43
|
this.fetchingProfileData = true;
|
|
50
44
|
try {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
state.configuration = JSON.parse(JSON.stringify(
|
|
45
|
+
const [error, data] = await getUnidyClient().profile.get();
|
|
46
|
+
if (error === null && data) {
|
|
47
|
+
state.configuration = JSON.parse(JSON.stringify(data));
|
|
54
48
|
state.configUpdateSource = "fetch";
|
|
55
49
|
state.errors = {};
|
|
56
50
|
state.flashErrors = {};
|
|
57
|
-
state.data = JSON.parse(JSON.stringify(
|
|
51
|
+
state.data = JSON.parse(JSON.stringify(data));
|
|
58
52
|
}
|
|
59
53
|
else {
|
|
60
|
-
state.flashErrors = {
|
|
54
|
+
state.flashErrors = { error: error || "unknown_error" };
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
|
-
catch (
|
|
64
|
-
captureException(
|
|
57
|
+
catch (err) {
|
|
58
|
+
captureException(err);
|
|
65
59
|
state.flashErrors = { error: t("errors.failed_to_load_profile") };
|
|
66
60
|
}
|
|
67
61
|
this.fetchingProfileData = false;
|
|
68
62
|
}
|
|
69
63
|
async submitProfile() {
|
|
70
|
-
const authInstance = await Auth.getInstance();
|
|
71
64
|
state.loading = true;
|
|
72
65
|
const { configuration, ...stateWithoutConfig } = state;
|
|
73
66
|
if (!validateRequiredFieldsUnchanged(stateWithoutConfig.data)) {
|
|
@@ -75,33 +68,21 @@ const Profile = /*@__PURE__*/ proxyCustomElement(class Profile extends HTMLEleme
|
|
|
75
68
|
return;
|
|
76
69
|
}
|
|
77
70
|
const updatedProfileData = buildPayload(stateWithoutConfig.data);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
data: updatedProfileData,
|
|
81
|
-
lang: unidyState.locale,
|
|
71
|
+
const [error, data] = await getUnidyClient().profile.update({
|
|
72
|
+
payload: updatedProfileData,
|
|
82
73
|
});
|
|
83
|
-
if (
|
|
74
|
+
if (error === null && data) {
|
|
84
75
|
state.loading = false;
|
|
85
|
-
state.configuration = JSON.parse(JSON.stringify(
|
|
76
|
+
state.configuration = JSON.parse(JSON.stringify(data));
|
|
86
77
|
state.configUpdateSource = "submit";
|
|
87
78
|
state.errors = {};
|
|
88
|
-
|
|
79
|
+
}
|
|
80
|
+
else if (error === "validation_error" && data && "flatErrors" in data) {
|
|
81
|
+
state.errors = data.flatErrors;
|
|
82
|
+
state.loading = false;
|
|
89
83
|
}
|
|
90
84
|
else {
|
|
91
|
-
|
|
92
|
-
state.errors = resp.data.flatErrors;
|
|
93
|
-
this.uProfileError.emit({
|
|
94
|
-
error: "profile_update_field_errors",
|
|
95
|
-
details: { fieldErrors: state.errors, httpStatus: resp?.status, responseData: resp?.data },
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
state.flashErrors = { [String(resp?.status)]: String(resp?.error) };
|
|
100
|
-
this.uProfileError.emit({
|
|
101
|
-
error: "profile_update_failed",
|
|
102
|
-
details: { flashErrors: state.flashErrors, httpStatus: resp?.status, responseData: resp?.data },
|
|
103
|
-
});
|
|
104
|
-
}
|
|
85
|
+
state.flashErrors = { error: error || "unknown_error" };
|
|
105
86
|
state.loading = false;
|
|
106
87
|
}
|
|
107
88
|
}
|
|
@@ -110,9 +91,8 @@ const Profile = /*@__PURE__*/ proxyCustomElement(class Profile extends HTMLEleme
|
|
|
110
91
|
state.data = cfg;
|
|
111
92
|
});
|
|
112
93
|
authStoreOnChange("token", (newToken) => {
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AAA,CAAC,CAAC,SAAS,CAAC,CAAO,KAEzB,EAAC,IAAI,EAAA,IAAA,EACH,CAAQ,CAAA,MAAA,EAAA,IAAA,CAAA,EACP,CAAC,cAAc,IAAI,QAAQ,IAAI,CAAe,CAAA,eAAA,EAAA,EAAA,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAI,CAAA,EACnF,SAAS,IAAI,CAAC,QAAQ,IAAI,CAAC,cAAc,IAAI,qBAAe,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,CAAC,CAAC,iBAAiB,CAAC,EAAA,CAAI,CAC3G,CACR;;QAGH,OAAO,cAAK,CAAC,CAAC,sBAAsB,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","unidyOnChange","profileState","Sentry.captureException","profileOnChange","authOnChange"],"sources":["src/profile/components/profile/profile.tsx"],"sourcesContent":["import * as Sentry from \"@sentry/browser\";\nimport { Component, Event, type EventEmitter, Host, h, Method, Prop, State } from \"@stencil/core\";\nimport { getUnidyClient } from \"../../../api\";\nimport { Auth } from \"../../../auth\";\nimport { onChange as authOnChange, authStore } from \"../../../auth/store/auth-store\";\nimport { t } from \"../../../i18n\";\nimport { onChange as unidyOnChange, unidyState } from \"../../../shared/store/unidy-store\";\nimport { buildPayload, validateRequiredFieldsUnchanged } from \"../../profile-helpers\";\nimport type { ProfileRaw } from \"../../store/profile-store\";\nimport { onChange as profileOnChange, state as profileState } from \"../../store/profile-store\";\n\n@Component({\n tag: \"u-profile\",\n shadow: false,\n})\nexport class Profile {\n @Prop() profileId?: string;\n @Prop() initialData: string | Record<string, string> = \"\";\n\n @Event() uProfileSuccess!: EventEmitter<{ message: string; payload: ProfileRaw }>;\n @Event() uProfileError!: EventEmitter<{\n error: string;\n details: {\n fieldErrors?: Record<string, string>;\n flashErrors?: Record<string, string>;\n httpStatus?: number;\n responseData?: unknown;\n };\n }>;\n\n @State() fetchingProfileData = false;\n\n constructor() {\n unidyOnChange(\"locale\", async (_locale) => {\n if (authStore.state.authenticated) await this.getTokenAndFetchProfile();\n });\n }\n\n async componentWillLoad() {\n if (this.initialData !== \"\") {\n profileState.data = typeof this.initialData === \"string\" ? JSON.parse(this.initialData) : this.initialData;\n } else if (authStore.state.authenticated) {\n await this.getTokenAndFetchProfile();\n }\n\n profileState.loading = false;\n }\n\n async getTokenAndFetchProfile() {\n const authInstance = await Auth.getInstance();\n\n const idToken = await authInstance.getToken();\n\n if (idToken && typeof idToken === \"string\") {\n await this.fetchProfileData(idToken as string);\n }\n }\n\n async fetchProfileData(idToken: string) {\n // avoid multiple requests\n if (this.fetchingProfileData) return;\n\n this.fetchingProfileData = true;\n try {\n const resp = await getUnidyClient().profile.fetchProfile({ idToken, lang: unidyState.locale });\n\n if (resp.success) {\n profileState.configuration = JSON.parse(JSON.stringify(resp.data)) as ProfileRaw;\n profileState.configUpdateSource = \"fetch\";\n profileState.errors = {};\n profileState.flashErrors = {};\n\n profileState.data = JSON.parse(JSON.stringify(resp.data)) as ProfileRaw;\n } else {\n profileState.flashErrors = { [String(resp?.status)]: String(resp?.error) };\n }\n } catch (error) {\n Sentry.captureException(\"Failed to fetch profile data:\", error);\n profileState.flashErrors = { error: t(\"errors.failed_to_load_profile\") };\n }\n this.fetchingProfileData = false;\n }\n\n @Method()\n async submitProfile() {\n const authInstance = await Auth.getInstance();\n\n profileState.loading = true;\n\n const { configuration, ...stateWithoutConfig } = profileState;\n\n if (!validateRequiredFieldsUnchanged(stateWithoutConfig.data)) {\n profileState.loading = false;\n return;\n }\n\n const updatedProfileData = buildPayload(stateWithoutConfig.data);\n\n const resp = await getUnidyClient().profile.updateProfile({\n idToken: (await authInstance.getToken()) as string,\n data: updatedProfileData,\n lang: unidyState.locale,\n });\n\n if (resp?.success) {\n profileState.loading = false;\n profileState.configuration = JSON.parse(JSON.stringify(resp.data));\n profileState.configUpdateSource = \"submit\";\n profileState.errors = {};\n this.uProfileSuccess.emit({ message: \"profile_updated_successfully\", payload: resp.data as ProfileRaw });\n } else {\n if (resp?.data && \"flatErrors\" in resp.data) {\n profileState.errors = resp.data.flatErrors as Record<string, string>;\n this.uProfileError.emit({\n error: \"profile_update_field_errors\",\n details: { fieldErrors: profileState.errors, httpStatus: resp?.status, responseData: resp?.data },\n });\n } else {\n profileState.flashErrors = { [String(resp?.status)]: String(resp?.error) };\n this.uProfileError.emit({\n error: \"profile_update_failed\",\n details: { flashErrors: profileState.flashErrors, httpStatus: resp?.status, responseData: resp?.data },\n });\n }\n profileState.loading = false;\n }\n }\n\n componentDidLoad() {\n profileOnChange(\"configuration\", (cfg) => {\n profileState.data = cfg as ProfileRaw;\n });\n\n authOnChange(\"token\", (newToken: string | null) => {\n const token = newToken ?? \"\";\n\n if (token) {\n this.fetchProfileData(token);\n }\n });\n }\n\n render() {\n const hasFieldErrors = Object.values(profileState.errors).some(Boolean);\n const errorMsg = Object.values(profileState.flashErrors).filter(Boolean).join(\", \");\n const wasSubmit = profileState.configUpdateSource === \"submit\";\n\n if (authStore.state.authenticated) {\n return this.fetchingProfileData ? (\n <div>{t(\"loading\")}</div>\n ) : (\n <Host>\n <slot />\n {!hasFieldErrors && errorMsg && <flash-message variant=\"error\" message={errorMsg} />}\n {wasSubmit && !errorMsg && !hasFieldErrors && <flash-message variant=\"success\" message={t(\"profile.updated\")} />}\n </Host>\n );\n }\n\n return <h2>{t(\"profile.signInToView\")}</h2>;\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"profile.js","mappings":";;;;;;;;;MAea,OAAO,iBAAAA,kBAAA,CAAA,MAAA,OAAA,SAAA,WAAA,CAAA;AACV,IAAA,SAAS;IACT,WAAW,GAAoC,EAAE;IAEhD,mBAAmB,GAAG,KAAK;AAEpC,IAAA,WAAA,CAAA,YAAA,EAAA;;;;;AACE,QAAAC,QAAa,CAAC,QAAQ,EAAE,OAAO,OAAO,KAAI;AACxC,YAAA,MAAM,IAAI,CAAC,gBAAgB,EAAE;AAC/B,SAAC,CAAC;AACH;AAED,IAA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OAAO,cAAK,CAAC,CAAC,sBAAsB,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","unidyOnChange","profileState","Sentry.captureException","profileOnChange","authOnChange"],"sources":["src/profile/components/profile/profile.tsx"],"sourcesContent":["import * as Sentry from \"@sentry/browser\";\nimport { Component, Host, Method, Prop, State, h } from \"@stencil/core\";\nimport { t } from \"../../../i18n\";\nimport { Auth } from \"../../../auth\";\nimport { getUnidyClient } from \"../../../api\";\nimport { authStore, onChange as authOnChange } from \"../../../auth/store/auth-store\";\nimport { state as profileState, onChange as profileOnChange } from \"../../store/profile-store\";\nimport { onChange as unidyOnChange } from \"../../../shared/store/unidy-store\";\nimport type { ProfileRaw } from \"../../store/profile-store\";\nimport { validateRequiredFieldsUnchanged, buildPayload } from \"../../profile-helpers\";\n\n@Component({\n tag: \"u-profile\",\n shadow: false,\n})\nexport class Profile {\n @Prop() profileId?: string;\n @Prop() initialData: string | Record<string, string> = \"\";\n\n @State() fetchingProfileData = false;\n\n constructor() {\n unidyOnChange(\"locale\", async (_locale) => {\n await this.fetchProfileData();\n });\n }\n\n async componentWillLoad() {\n if (this.initialData !== \"\") {\n profileState.data = typeof this.initialData === \"string\" ? JSON.parse(this.initialData) : this.initialData;\n } else {\n await this.fetchProfileData();\n }\n\n profileState.loading = false;\n }\n\n async fetchProfileData() {\n // avoid multiple requests\n if (this.fetchingProfileData) return;\n\n const authInstance = await Auth.getInstance();\n const isAuthenticated = await authInstance.isAuthenticated();\n if (!isAuthenticated) {\n // Handle unauthenticated state the same as an unauthorized error from backend\n profileState.flashErrors = { error: t(\"errors.unauthorized\") };\n return;\n }\n\n this.fetchingProfileData = true;\n try {\n const [error, data] = await getUnidyClient().profile.get();\n\n if (error === null && data) {\n profileState.configuration = JSON.parse(JSON.stringify(data)) as ProfileRaw;\n profileState.configUpdateSource = \"fetch\";\n profileState.errors = {};\n profileState.flashErrors = {};\n\n profileState.data = JSON.parse(JSON.stringify(data)) as ProfileRaw;\n } else {\n profileState.flashErrors = { error: error || \"unknown_error\" };\n }\n } catch (err) {\n Sentry.captureException(err);\n profileState.flashErrors = { error: t(\"errors.failed_to_load_profile\") };\n }\n this.fetchingProfileData = false;\n }\n\n @Method()\n async submitProfile() {\n profileState.loading = true;\n\n const { configuration, ...stateWithoutConfig } = profileState;\n\n if (!validateRequiredFieldsUnchanged(stateWithoutConfig.data)) {\n profileState.loading = false;\n return;\n }\n\n const updatedProfileData = buildPayload(stateWithoutConfig.data);\n\n const [error, data] = await getUnidyClient().profile.update({\n payload: updatedProfileData,\n });\n\n if (error === null && data) {\n profileState.loading = false;\n profileState.configuration = JSON.parse(JSON.stringify(data));\n profileState.configUpdateSource = \"submit\";\n profileState.errors = {};\n } else if (error === \"validation_error\" && data && \"flatErrors\" in data) {\n profileState.errors = data.flatErrors as Record<string, string>;\n profileState.loading = false;\n } else {\n profileState.flashErrors = { error: error || \"unknown_error\" };\n profileState.loading = false;\n }\n }\n\n componentDidLoad() {\n profileOnChange(\"configuration\", (cfg) => {\n profileState.data = cfg as ProfileRaw;\n });\n\n authOnChange(\"token\", (newToken: string | null) => {\n if (newToken) {\n this.fetchProfileData();\n }\n });\n }\n\n render() {\n const hasFieldErrors = Object.values(profileState.errors).some(Boolean);\n const errorMsg = Object.values(profileState.flashErrors).filter(Boolean).join(\", \");\n const wasSubmit = profileState.configUpdateSource === \"submit\";\n\n if (authStore.state.authenticated) {\n return this.fetchingProfileData ? (\n <div>{t(\"loading\")}</div>\n ) : (\n <Host>\n <slot />\n {!hasFieldErrors && errorMsg && <flash-message variant=\"error\" message={errorMsg} />}\n {wasSubmit && !errorMsg && !hasFieldErrors && <flash-message variant=\"success\" message={t(\"profile.updated\")} />}\n </Host>\n );\n }\n\n return <h2>{t(\"profile.signInToView\")}</h2>;\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
|
|
3
|
-
const spinnerCss = "/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer theme{:host,:root{--u-animate-spin:spin 1s linear infinite;--u-font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--u-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--u-default-font-family:var(--u-font-sans);--u-default-mono-font-family:var(--u-font-mono);--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{font-family:var(--u-default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--u-default-font-feature-settings,normal);font-variation-settings:var(--u-default-font-variation-settings,normal);-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);tab-size:4;-webkit-tap-highlight-color:transparent;line-height:1.5}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--u-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--u-default-mono-font-feature-settings,normal);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--u-default-mono-font-variation-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:currentColor;color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.u\\:inline-flex{display:inline-flex}.u\\:h-\\[1em\\]{height:1em}.u\\:w-\\[1em\\]{width:1em}.u\\:animate-spin{animation:var(--u-animate-spin)}.u\\:items-center{align-items:center}.u\\:
|
|
3
|
+
const spinnerCss = "/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer theme{:host,:root{--u-animate-spin:spin 1s linear infinite;--u-font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--u-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--u-default-font-family:var(--u-font-sans);--u-default-mono-font-family:var(--u-font-mono);--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{font-family:var(--u-default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--u-default-font-feature-settings,normal);font-variation-settings:var(--u-default-font-variation-settings,normal);-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);tab-size:4;-webkit-tap-highlight-color:transparent;line-height:1.5}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--u-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--u-default-mono-font-feature-settings,normal);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--u-default-mono-font-variation-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:currentColor;color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.u\\:flex{display:flex}.u\\:justify-center{justify-content:center}.u\\:disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.u\\:disabled\\:opacity-50:disabled{opacity:.5}.u\\:inline-flex{display:inline-flex}.u\\:h-\\[1em\\]{height:1em}.u\\:w-\\[1em\\]{width:1em}.u\\:animate-spin{animation:var(--u-animate-spin)}.u\\:items-center{align-items:center}.u\\:rounded-\\[50\\%\\]{border-radius:50%}} /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components;@layer utilities{}@keyframes spin{to{transform:rotate(1turn)}} /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components;@layer utilities{.u\\:justify-end{justify-content:flex-end}} /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-ring-offset-width:0px;--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer base{}@layer components;@layer utilities{.container{width:100%}.border{border-style:var(--tw-border-style);border-width:1px}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}:host{font-size:var(--spinner-font-size,20px)}.spinner-inner{border-top:.1em solid var(--spinner-color-secondary,#ccc);border:.1em solid var(--spinner-color-secondary,#ccc);border-top-color:var(--spinner-color-primary,#333)}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}";
|
|
4
4
|
|
|
5
5
|
const Spinner = /*@__PURE__*/ proxyCustomElement(class Spinner extends HTMLElement {
|
|
6
6
|
constructor(registerHost) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"spinner.js","mappings":";;AAAA,MAAM,UAAU,GAAG
|
|
1
|
+
{"file":"spinner.js","mappings":";;AAAA,MAAM,UAAU,GAAG,2xSAA2xS;;MCOjyS,OAAO,iBAAAA,kBAAA,CAAA,MAAA,OAAA,SAAA,WAAA,CAAA;;;;;;;;IAClB,MAAM,GAAA;AACJ,QAAA,QACE,CAAC,CAAA,IAAI,EAAC,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,+CAA+C,EAAA,EAEzD,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAC,kEAAkE,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAY,YAAA,EAAA,SAAS,EAAG,CAAA,CAC7H;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement"],"sources":["src/shared/components/spinner/spinner.css?tag=u-spinner&encapsulation=shadow","src/shared/components/spinner/spinner.tsx"],"sourcesContent":[":host {\n font-size: var(--spinner-font-size, 20px);\n}\n\n.spinner-inner {\n border: 0.1em solid var(--spinner-color-secondary, #ccc);\n border-top: 0.1em solid var(--spinner-color-primary, #333);\n}\n","import { Component, h, Host } from \"@stencil/core\";\n\n@Component({\n tag: \"u-spinner\",\n styleUrl: \"spinner.css\",\n shadow: true,\n})\nexport class Spinner {\n render() {\n return (\n <Host class=\"u:inline-flex u:items-center u:justify-center\">\n {/* biome-ignore lint/a11y/useSemanticElements: spinner is a visual element, output tag not appropriate */}\n <div class=\"spinner-inner u:w-[1em] u:h-[1em] u:rounded-[50%] u:animate-spin\" part=\"spinner\" role=\"status\" aria-label=\"Loading\" />\n </Host>\n );\n }\n}\n"],"version":3}
|