@react-pakistan/util-functions 1.25.90 → 2.0.2
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/README.md +74 -315
- package/constants/api-methods.d.ts +3 -1
- package/constants/api-methods.js +1 -15
- package/constants/cache-time.d.ts +7 -5
- package/constants/cache-time.js +1 -8
- package/constants/countries-timezones.d.ts +4 -2
- package/constants/countries-timezones.js +1 -1411
- package/constants/currencies.d.ts +4 -2
- package/constants/currencies.js +1 -1076
- package/constants/dial-codes.d.ts +5 -3
- package/constants/dial-codes.js +1 -1216
- package/constants/layout-direction.d.ts +3 -1
- package/constants/layout-direction.js +1 -8
- package/constants/react-pakistan-meta.d.ts +4 -2
- package/constants/react-pakistan-meta.js +1 -35
- package/constants/react-pakistan.d.ts +5 -3
- package/constants/react-pakistan.js +12 -104
- package/constants/select-value-delimiter.d.ts +3 -1
- package/constants/select-value-delimiter.js +1 -13
- package/constants/social-media-colors.d.ts +3 -1
- package/constants/social-media-colors.js +1 -42
- package/constants/social-media-sizes.d.ts +6 -4
- package/constants/social-media-sizes.js +1 -327
- package/constants/user-roles.d.ts +3 -1
- package/constants/user-roles.js +1 -9
- package/edu-pilot-pro/types/academics.d.ts +2 -266
- package/edu-pilot-pro/types/academics.js +1 -9
- package/edu-pilot-pro/types/admission.d.ts +803 -10
- package/edu-pilot-pro/types/admission.js +1 -7
- package/edu-pilot-pro/types/communication.d.ts +2 -165
- package/edu-pilot-pro/types/communication.js +1 -8
- package/edu-pilot-pro/types/enums.d.ts +30 -28
- package/edu-pilot-pro/types/enums.js +1 -445
- package/edu-pilot-pro/types/finance.d.ts +2 -128
- package/edu-pilot-pro/types/finance.js +1 -8
- package/edu-pilot-pro/types/index.d.ts +2 -12
- package/edu-pilot-pro/types/index.js +1 -28
- package/edu-pilot-pro/types/user-management.d.ts +2 -236
- package/edu-pilot-pro/types/user-management.js +1 -8
- package/factory/generic-component-factory.d.ts +12 -9
- package/factory/generic-component-factory.js +1 -131
- package/factory/generic-module-factory.d.ts +14 -10
- package/factory/generic-module-factory.js +1 -190
- package/general/basic-get.d.ts +8 -1
- package/general/basic-get.js +1 -83
- package/general/basic-post.d.ts +8 -1
- package/general/basic-post.js +1 -70
- package/general/calculate-pages.d.ts +9 -1
- package/general/calculate-pages.js +1 -7
- package/general/camel-to-sentence-case.d.ts +3 -1
- package/general/camel-to-sentence-case.js +1 -20
- package/general/check-even-odd-length.d.ts +3 -1
- package/general/check-even-odd-length.js +1 -17
- package/general/clear-cache.d.ts +7 -2
- package/general/clear-cache.js +1 -12
- package/general/cnic-formatter.d.ts +16 -3
- package/general/cnic-formatter.js +1 -53
- package/general/convert-url-to-base64.d.ts +8 -6
- package/general/convert-url-to-base64.js +1 -231
- package/general/countries.d.ts +5 -3
- package/general/countries.js +1 -514
- package/general/create-date.d.ts +3 -1
- package/general/create-date.js +1 -22
- package/general/crypto.d.ts +4 -2
- package/general/crypto.js +1 -45
- package/general/currencies.d.ts +2 -0
- package/general/currencies.js +0 -1077
- package/general/delete-image-from-private-supabase.d.ts +10 -2
- package/general/delete-image-from-private-supabase.js +1 -66
- package/general/delete-image-from-public-supabase.d.ts +10 -2
- package/general/delete-image-from-public-supabase.js +1 -66
- package/general/download-from-url.d.ts +8 -1
- package/general/download-from-url.js +1 -82
- package/general/dynamic-page-limit.d.ts +9 -3
- package/general/dynamic-page-limit.js +1 -7
- package/general/enum-to-text.d.ts +8 -1
- package/general/enum-to-text.js +1 -11
- package/general/fetch-data.d.ts +16 -4
- package/general/fetch-data.js +1 -95
- package/general/fetch-supabase-image.d.ts +11 -2
- package/general/fetch-supabase-image.js +1 -67
- package/general/fetch-supabase-private-assets.d.ts +11 -2
- package/general/fetch-supabase-private-assets.js +1 -69
- package/general/format-date.d.ts +10 -2
- package/general/format-date.js +1 -49
- package/general/format-number.d.ts +12 -2
- package/general/format-number.js +1 -35
- package/general/format-phone-display.d.ts +9 -1
- package/general/format-phone-display.js +1 -32
- package/general/format-phone.d.ts +10 -2
- package/general/format-phone.js +1 -20
- package/general/format-pricing.d.ts +8 -1
- package/general/format-pricing.js +1 -23
- package/general/format-secs.d.ts +8 -1
- package/general/format-secs.js +1 -21
- package/general/format-time.d.ts +8 -2
- package/general/format-time.js +1 -38
- package/general/format-value.d.ts +8 -1
- package/general/format-value.js +1 -7
- package/general/full-month-range.d.ts +3 -2
- package/general/full-month-range.js +1 -24
- package/general/full-year-range.d.ts +3 -2
- package/general/full-year-range.js +1 -20
- package/general/generate-article-schema.d.ts +3 -2
- package/general/generate-article-schema.js +1 -100
- package/general/generate-blog-schema.d.ts +3 -2
- package/general/generate-blog-schema.js +1 -32
- package/general/generate-book-schema.d.ts +3 -2
- package/general/generate-book-schema.js +1 -109
- package/general/generate-breadcrumb-schema.d.ts +3 -2
- package/general/generate-breadcrumb-schema.js +1 -34
- package/general/generate-carousel-schema.d.ts +3 -2
- package/general/generate-carousel-schema.js +1 -172
- package/general/generate-course-schema.d.ts +3 -2
- package/general/generate-course-schema.js +1 -124
- package/general/generate-dataset-schema.d.ts +3 -2
- package/general/generate-dataset-schema.js +1 -156
- package/general/generate-discussion-forum-schema.d.ts +3 -2
- package/general/generate-discussion-forum-schema.js +1 -67
- package/general/generate-education-schema.d.ts +3 -2
- package/general/generate-education-schema.js +1 -137
- package/general/generate-employer-aggregate-rating-schema.d.ts +3 -2
- package/general/generate-employer-aggregate-rating-schema.js +1 -64
- package/general/generate-event-schema.d.ts +3 -2
- package/general/generate-event-schema.js +1 -214
- package/general/generate-faq-schema.d.ts +3 -2
- package/general/generate-faq-schema.js +1 -43
- package/general/generate-grid.d.ts +3 -2
- package/general/generate-grid.js +1 -55
- package/general/generate-image-metadata-schema.d.ts +3 -2
- package/general/generate-image-metadata-schema.js +1 -73
- package/general/generate-job-posting-schema.d.ts +3 -2
- package/general/generate-job-posting-schema.js +1 -120
- package/general/generate-local-business-schema.d.ts +3 -2
- package/general/generate-local-business-schema.js +1 -75
- package/general/generate-math-solver-schema.d.ts +3 -2
- package/general/generate-math-solver-schema.js +1 -83
- package/general/generate-movie-carousel-schema.d.ts +3 -2
- package/general/generate-movie-carousel-schema.js +1 -160
- package/general/generate-organization-schema.d.ts +3 -2
- package/general/generate-organization-schema.js +1 -39
- package/general/generate-profile-page-schema.d.ts +3 -2
- package/general/generate-profile-page-schema.js +1 -82
- package/general/generate-qa-page-schema.d.ts +3 -2
- package/general/generate-qa-page-schema.js +1 -67
- package/general/generate-recipe-schema.d.ts +3 -2
- package/general/generate-recipe-schema.js +1 -104
- package/general/generate-ref.d.ts +8 -2
- package/general/generate-ref.js +1 -12
- package/general/generate-review-snippet-schema.d.ts +3 -2
- package/general/generate-review-snippet-schema.js +1 -137
- package/general/generate-shopping-loyalty-program-schema.d.ts +3 -2
- package/general/generate-shopping-loyalty-program-schema.js +1 -59
- package/general/generate-shopping-merchant-listing-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-listing-schema.js +1 -153
- package/general/generate-shopping-merchant-return-policy-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-return-policy-schema.js +1 -68
- package/general/generate-shopping-merchant-shipping-policy-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-shipping-policy-schema.js +1 -74
- package/general/generate-shopping-overview-schema.d.ts +3 -2
- package/general/generate-shopping-overview-schema.js +1 -157
- package/general/generate-shopping-product-snippet-schema.d.ts +3 -2
- package/general/generate-shopping-product-snippet-schema.js +1 -167
- package/general/generate-shopping-variants-schema.d.ts +3 -2
- package/general/generate-shopping-variants-schema.js +1 -143
- package/general/generate-software-app-schema.d.ts +3 -2
- package/general/generate-software-app-schema.js +1 -143
- package/general/generate-speakable-schema.d.ts +3 -2
- package/general/generate-speakable-schema.js +1 -139
- package/general/generate-subscription-schema.d.ts +3 -2
- package/general/generate-subscription-schema.js +1 -133
- package/general/generate-vacation-rental-schema.d.ts +3 -2
- package/general/generate-vacation-rental-schema.js +1 -135
- package/general/generate-video-schema.d.ts +3 -2
- package/general/generate-video-schema.js +1 -163
- package/general/generic-cache.d.ts +17 -15
- package/general/generic-cache.js +1 -659
- package/general/get-available-page-limit.d.ts +8 -2
- package/general/get-available-page-limit.js +1 -31
- package/general/get-calendar-current-month.d.ts +11 -3
- package/general/get-calendar-current-month.js +1 -31
- package/general/get-calendar-dates.d.ts +11 -3
- package/general/get-calendar-dates.js +1 -42
- package/general/get-calendar-next-month.d.ts +12 -3
- package/general/get-calendar-next-month.js +1 -32
- package/general/get-calendar-previous-month.d.ts +12 -3
- package/general/get-calendar-previous-month.js +1 -36
- package/general/get-current-year.d.ts +7 -1
- package/general/get-current-year.js +1 -5
- package/general/get-day-name.d.ts +5 -3
- package/general/get-day-name.js +1 -14
- package/general/get-dial-code.d.ts +8 -1
- package/general/get-dial-code.js +1 -8
- package/general/get-full-name.d.ts +9 -2
- package/general/get-full-name.js +1 -8
- package/general/get-href.d.ts +3 -1
- package/general/get-href.js +1 -13
- package/general/get-month-name.d.ts +5 -3
- package/general/get-month-name.js +1 -19
- package/general/get-month-number.d.ts +5 -3
- package/general/get-month-number.js +1 -29
- package/general/get-number-of-days-in-month.d.ts +9 -2
- package/general/get-number-of-days-in-month.js +1 -12
- package/general/get-pathname.d.ts +3 -1
- package/general/get-pathname.js +1 -16
- package/general/get-week-day.d.ts +8 -1
- package/general/get-week-day.js +1 -9
- package/general/image-url-to-base64.d.ts +3 -1
- package/general/image-url-to-base64.js +1 -80
- package/general/is-created-or-updated.d.ts +3 -1
- package/general/is-created-or-updated.js +1 -26
- package/general/is-next-button-disabled.d.ts +9 -1
- package/general/is-next-button-disabled.js +1 -5
- package/general/is-odd.d.ts +3 -1
- package/general/is-odd.js +1 -13
- package/general/is-previous-button-disabled.d.ts +8 -1
- package/general/is-previous-button-disabled.js +1 -7
- package/general/linear-gradients.d.ts +4 -2
- package/general/linear-gradients.js +1 -52
- package/general/multi-part-search.d.ts +10 -2
- package/general/multi-part-search.js +1 -16
- package/general/normalize-phone.d.ts +15 -2
- package/general/normalize-phone.js +1 -40
- package/general/parse-frontmatter.d.ts +11 -4
- package/general/parse-frontmatter.js +2 -35
- package/general/remove-data-image-prefix.d.ts +8 -1
- package/general/remove-data-image-prefix.js +1 -7
- package/general/repeat-times.d.ts +3 -1
- package/general/repeat-times.js +1 -21
- package/general/resolve-anchor-link.d.ts +3 -1
- package/general/resolve-anchor-link.js +1 -26
- package/general/resolve-current-date.d.ts +3 -1
- package/general/resolve-current-date.js +1 -22
- package/general/resolve-grid.d.ts +3 -1
- package/general/resolve-grid.js +1 -18
- package/general/resolve-initials.d.ts +3 -1
- package/general/resolve-initials.js +1 -17
- package/general/set-timezone.d.ts +11 -1
- package/general/set-timezone.js +1 -12
- package/general/slugify.d.ts +3 -1
- package/general/slugify.js +1 -24
- package/general/text-to-enum.d.ts +8 -1
- package/general/text-to-enum.js +1 -10
- package/general/text-to-sentence-case.d.ts +3 -1
- package/general/text-to-sentence-case.js +1 -16
- package/general/time-out.d.ts +3 -1
- package/general/time-out.js +1 -16
- package/general/time-zones.d.ts +3 -1
- package/general/time-zones.js +1 -437
- package/general/truncate-text.d.ts +3 -1
- package/general/truncate-text.js +1 -18
- package/general/type.d.ts +3 -1
- package/general/type.js +1 -2
- package/general/upload-blob-to-private-supabase.d.ts +14 -2
- package/general/upload-blob-to-private-supabase.js +1 -62
- package/general/upload-blob-to-public-supabase.d.ts +14 -2
- package/general/upload-blob-to-public-supabase.js +1 -62
- package/general/upload-image-to-private-supabase.d.ts +15 -3
- package/general/upload-image-to-private-supabase.js +1 -66
- package/general/upload-image-to-public-supabase.d.ts +15 -3
- package/general/upload-image-to-public-supabase.js +1 -66
- package/general/url-to-sentence-case.d.ts +3 -1
- package/general/url-to-sentence-case.js +1 -19
- package/general/validate-comment.d.ts +3 -1
- package/general/validate-comment.js +1 -21
- package/general/validate-email.d.ts +3 -1
- package/general/validate-email.js +1 -24
- package/general/validate-form.d.ts +12 -3
- package/general/validate-form.js +1 -29
- package/general/validate-name.d.ts +3 -1
- package/general/validate-name.js +1 -21
- package/hooks/use-change.d.ts +11 -2
- package/hooks/use-change.js +1 -23
- package/hooks/use-debounce.d.ts +10 -1
- package/hooks/use-debounce.js +1 -14
- package/hooks/use-fetch.d.ts +7 -5
- package/hooks/use-fetch.js +1 -239
- package/hooks/use-force-render.d.ts +6 -2
- package/hooks/use-force-render.js +1 -17
- package/hooks/use-ip-geo-location.d.ts +8 -1
- package/hooks/use-ip-geo-location.js +1 -79
- package/hooks/use-is-mobile.d.ts +8 -1
- package/hooks/use-is-mobile.js +1 -22
- package/hooks/use-module-entity-v2.d.ts +7 -4
- package/hooks/use-module-entity-v2.js +1 -188
- package/hooks/use-module-entity.d.ts +7 -4
- package/hooks/use-module-entity.js +1 -177
- package/hooks/use-phone-formatter.d.ts +10 -2
- package/hooks/use-phone-formatter.js +1 -23
- package/hooks/use-position.d.ts +6 -3
- package/hooks/use-position.js +1 -43
- package/hooks/use-rtl.d.ts +4 -2
- package/hooks/use-rtl.js +1 -84
- package/hooks/use-sticky.d.ts +3 -1
- package/hooks/use-sticky.js +1 -39
- package/hooks/use-toggle-state.d.ts +3 -2
- package/hooks/use-toggle-state.js +1 -26
- package/hooks/use-window-event-listener.d.ts +9 -1
- package/hooks/use-window-event-listener.js +1 -11
- package/hooks/with-seo.d.ts +11 -2
- package/hooks/with-seo.js +1 -37
- package/local-storage/get-storage-value.d.ts +5 -2
- package/local-storage/get-storage-value.js +1 -20
- package/local-storage/remove-storage-value.d.ts +3 -1
- package/local-storage/remove-storage-value.js +1 -14
- package/local-storage/set-storage-value.d.ts +3 -1
- package/local-storage/set-storage-value.js +1 -14
- package/local-storage/type.d.ts +3 -1
- package/local-storage/type.js +1 -2
- package/npm.d.d.ts +2 -0
- package/npm.d.js +0 -0
- package/package.json +21 -19
- package/{api/stellar-solutions → stellar-solution}/types/common.d.ts +4 -2
- package/stellar-solution/types/common.js +1 -0
- package/{api/stellar-solutions → stellar-solution}/types/erp.d.ts +36 -33
- package/stellar-solution/types/erp.js +1 -0
- package/stellar-solution/types/index.d.ts +3 -0
- package/stellar-solution/types/index.js +1 -0
- package/{api/stellar-solutions → stellar-solution}/types/pos.d.ts +27 -24
- package/stellar-solution/types/pos.js +1 -0
- package/storybook/generate-sitemap.d.ts +3 -1
- package/storybook/generate-sitemap.js +17 -26
- package/storybook/preview.d.ts +4 -2
- package/storybook/preview.js +1 -62
- package/storybook/react-design-story-script.d.ts +3 -1
- package/storybook/react-design-story-script.js +5 -27
- package/storybook/react-emoji-collection.d.ts +3 -1
- package/storybook/react-emoji-collection.js +10 -55
- package/storybook/react-emoji-story-script.d.ts +3 -1
- package/storybook/react-emoji-story-script.js +5 -31
- package/storybook/react-emoji-story-template.d.ts +3 -1
- package/storybook/react-emoji-story-template.js +45 -15
- package/storybook/react-icon-collection.d.ts +3 -1
- package/storybook/react-icon-collection.js +10 -42
- package/storybook/react-icon-story-script.d.ts +3 -1
- package/storybook/react-icon-story-script.js +5 -27
- package/storybook/react-icon-story-template.d.ts +3 -1
- package/storybook/react-icon-story-template.js +45 -14
- package/storybook/react-logo-collection.d.ts +3 -1
- package/storybook/react-logo-collection.js +10 -42
- package/storybook/react-logo-story-script.d.ts +3 -1
- package/storybook/react-logo-story-script.js +5 -27
- package/storybook/react-logo-story-template.d.ts +3 -1
- package/storybook/react-logo-story-template.js +45 -14
- package/storybook/react-pakistan-theme.d.ts +3 -1
- package/storybook/react-pakistan-theme.js +1 -31
- package/storybook/responsive-args.d.ts +11 -10
- package/storybook/responsive-args.js +1 -19
- package/storybook/responsive-component.d.ts +4 -2
- package/storybook/responsive-component.js +37 -23
- package/storybook/responsive-screens.d.ts +3 -1
- package/storybook/responsive-screens.js +1 -109
- package/storybook/theme.d.ts +17 -15
- package/storybook/theme.js +1 -1022
- package/api/stellar-solutions/app-user/index.d.ts +0 -51
- package/api/stellar-solutions/app-user/index.js +0 -210
- package/api/stellar-solutions/bank/index.d.ts +0 -59
- package/api/stellar-solutions/bank/index.js +0 -210
- package/api/stellar-solutions/branch/index.d.ts +0 -58
- package/api/stellar-solutions/branch/index.js +0 -220
- package/api/stellar-solutions/company/index.d.ts +0 -57
- package/api/stellar-solutions/company/index.js +0 -218
- package/api/stellar-solutions/company-report/index.d.ts +0 -15
- package/api/stellar-solutions/company-report/index.js +0 -74
- package/api/stellar-solutions/constants.d.ts +0 -19
- package/api/stellar-solutions/constants.js +0 -22
- package/api/stellar-solutions/contact/index.d.ts +0 -56
- package/api/stellar-solutions/contact/index.js +0 -217
- package/api/stellar-solutions/currency/index.d.ts +0 -55
- package/api/stellar-solutions/currency/index.js +0 -212
- package/api/stellar-solutions/customer/index.d.ts +0 -68
- package/api/stellar-solutions/customer/index.js +0 -249
- package/api/stellar-solutions/expense/index.d.ts +0 -58
- package/api/stellar-solutions/expense/index.js +0 -229
- package/api/stellar-solutions/expense-category/index.d.ts +0 -53
- package/api/stellar-solutions/expense-category/index.js +0 -214
- package/api/stellar-solutions/lead/index.d.ts +0 -51
- package/api/stellar-solutions/lead/index.js +0 -206
- package/api/stellar-solutions/menu-order/index.d.ts +0 -53
- package/api/stellar-solutions/menu-order/index.js +0 -202
- package/api/stellar-solutions/payment/index.d.ts +0 -65
- package/api/stellar-solutions/payment/index.js +0 -230
- package/api/stellar-solutions/payment-mode/index.d.ts +0 -53
- package/api/stellar-solutions/payment-mode/index.js +0 -191
- package/api/stellar-solutions/preference/index.d.ts +0 -25
- package/api/stellar-solutions/preference/index.js +0 -114
- package/api/stellar-solutions/product/index.d.ts +0 -64
- package/api/stellar-solutions/product/index.js +0 -235
- package/api/stellar-solutions/product-category/index.d.ts +0 -51
- package/api/stellar-solutions/product-category/index.js +0 -212
- package/api/stellar-solutions/profile/index.d.ts +0 -78
- package/api/stellar-solutions/profile/index.js +0 -234
- package/api/stellar-solutions/quote-invoice/index.d.ts +0 -97
- package/api/stellar-solutions/quote-invoice/index.js +0 -369
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +0 -15
- package/api/stellar-solutions/quote-invoice-report/index.js +0 -74
- package/api/stellar-solutions/tax/index.d.ts +0 -55
- package/api/stellar-solutions/tax/index.js +0 -224
- package/api/stellar-solutions/types/common.js +0 -22
- package/api/stellar-solutions/types/erp.js +0 -73
- package/api/stellar-solutions/types/index.d.ts +0 -3
- package/api/stellar-solutions/types/index.js +0 -19
- package/api/stellar-solutions/types/pos.js +0 -61
- package/constants/index.d.ts +0 -12
- package/constants/index.js +0 -28
- package/factory/index.d.ts +0 -2
- package/factory/index.js +0 -18
- package/general/index.d.ts +0 -95
- package/general/index.js +0 -111
- package/index.d.ts +0 -28
- package/index.js +0 -44
- package/local-storage/index.d.ts +0 -4
- package/local-storage/index.js +0 -20
- package/setupTests.d.ts +0 -1
- package/setupTests.js +0 -52
- package/storybook/index.d.ts +0 -17
- package/storybook/index.js +0 -33
package/hooks/use-debounce.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useDebounce = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useDebounce = function (value, timeout) {
|
|
6
|
-
if (timeout === void 0) { timeout = 500; }
|
|
7
|
-
var _a = (0, react_1.useState)(value), state = _a[0], setState = _a[1];
|
|
8
|
-
(0, react_1.useEffect)(function () {
|
|
9
|
-
var handler = setTimeout(function () { return setState(value); }, timeout);
|
|
10
|
-
return function () { return clearTimeout(handler); };
|
|
11
|
-
}, [value, timeout]);
|
|
12
|
-
return state;
|
|
13
|
-
};
|
|
14
|
-
exports.useDebounce = useDebounce;
|
|
1
|
+
var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var s in t)c(e,s,{get:t[s],enumerable:!0})},f=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of i(t))!m.call(e,r)&&r!==s&&c(e,r,{get:()=>t[r],enumerable:!(n=u(t,r))||n.enumerable});return e};var g=e=>f(c({},"__esModule",{value:!0}),e);var p={};a(p,{useDebounce:()=>b});module.exports=g(p);var o=require("react");const b=(e,t=500)=>{const[s,n]=(0,o.useState)(e);return(0,o.useEffect)(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s};0&&(module.exports={useDebounce});
|
package/hooks/use-fetch.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface FetchResult {
|
|
2
2
|
data: any;
|
|
3
3
|
error: any;
|
|
4
4
|
status?: number;
|
|
5
5
|
ok?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface FetchConfig extends Omit<RequestInit, 'credentials'> {
|
|
8
8
|
autoFetch?: boolean;
|
|
9
9
|
callback?: (result: FetchResult) => void;
|
|
10
10
|
/**
|
|
@@ -26,15 +26,17 @@ export interface FetchConfig extends Omit<RequestInit, 'credentials'> {
|
|
|
26
26
|
*/
|
|
27
27
|
params?: Record<string, any>;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
interface Return {
|
|
30
30
|
apiResult: API_RESULT | undefined;
|
|
31
31
|
data: any;
|
|
32
32
|
error: any;
|
|
33
33
|
fetchNow: (url?: string, config?: FetchConfig) => void;
|
|
34
34
|
loading: boolean;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
declare enum API_RESULT {
|
|
37
37
|
SUCCESS = "SUCCESS",
|
|
38
38
|
ERROR = "ERROR"
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
declare const useFetch: (url: string, config?: FetchConfig, deps?: Array<string> | Array<any>) => Return;
|
|
41
|
+
|
|
42
|
+
export { API_RESULT, type FetchConfig, type FetchResult, type Return, useFetch };
|
package/hooks/use-fetch.js
CHANGED
|
@@ -1,239 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
61
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
62
|
-
if (ar || !(i in from)) {
|
|
63
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
64
|
-
ar[i] = from[i];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
68
|
-
};
|
|
69
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
exports.useFetch = exports.API_RESULT = void 0;
|
|
71
|
-
var react_1 = require("react");
|
|
72
|
-
var API_RESULT;
|
|
73
|
-
(function (API_RESULT) {
|
|
74
|
-
API_RESULT["SUCCESS"] = "SUCCESS";
|
|
75
|
-
API_RESULT["ERROR"] = "ERROR";
|
|
76
|
-
})(API_RESULT || (exports.API_RESULT = API_RESULT = {}));
|
|
77
|
-
var useFetch = function (url, config, deps) {
|
|
78
|
-
if (config === void 0) { config = {}; }
|
|
79
|
-
if (deps === void 0) { deps = []; }
|
|
80
|
-
var callback = config.callback, _a = config.autoFetch, autoFetch = _a === void 0 ? false : _a, defaultOptions = __rest(config, ["callback", "autoFetch"]);
|
|
81
|
-
var _b = (0, react_1.useState)(null), data = _b[0], setData = _b[1];
|
|
82
|
-
var _c = (0, react_1.useState)(null), error = _c[0], setError = _c[1];
|
|
83
|
-
var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
|
|
84
|
-
var _e = (0, react_1.useState)(undefined), apiResult = _e[0], setApiResult = _e[1];
|
|
85
|
-
var abortControllerRef = (0, react_1.useRef)(null);
|
|
86
|
-
var isMounted = (0, react_1.useRef)(true);
|
|
87
|
-
var autoFetchedRef = (0, react_1.useRef)(false);
|
|
88
|
-
(0, react_1.useEffect)(function () {
|
|
89
|
-
isMounted.current = true;
|
|
90
|
-
return function () {
|
|
91
|
-
var _a;
|
|
92
|
-
isMounted.current = false;
|
|
93
|
-
(_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
94
|
-
};
|
|
95
|
-
}, []);
|
|
96
|
-
var fetchNow = (0, react_1.useCallback)(function (overrideUrl, overrideOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var finalUrl, _a, defaultParams, restDefaultOptions, _b, overrideParams, restOverrideOptions, mergedParams, finalOptions, method, credOverride, credDefault, hashIndex, hash, basePart, searchIndex, pathname, existingSearch, searchParams_1, newSearch, controller, response, parsed, _c, err, err_1;
|
|
98
|
-
return __generator(this, function (_d) {
|
|
99
|
-
switch (_d.label) {
|
|
100
|
-
case 0:
|
|
101
|
-
finalUrl = overrideUrl || url;
|
|
102
|
-
_a = defaultOptions || {}, defaultParams = _a.params, restDefaultOptions = __rest(_a, ["params"]);
|
|
103
|
-
_b = overrideOptions || {}, overrideParams = _b.params, restOverrideOptions = __rest(_b, ["params"]);
|
|
104
|
-
mergedParams = __assign(__assign({}, (defaultParams || {})), (overrideParams || {}));
|
|
105
|
-
finalOptions = __assign(__assign(__assign({}, restDefaultOptions), restOverrideOptions), { headers: __assign(__assign({}, (restDefaultOptions.headers || {})), (restOverrideOptions.headers || {})) });
|
|
106
|
-
method = (finalOptions.method || 'GET')
|
|
107
|
-
.toString()
|
|
108
|
-
.toUpperCase();
|
|
109
|
-
credOverride = restOverrideOptions.credentials;
|
|
110
|
-
credDefault = restDefaultOptions.credentials;
|
|
111
|
-
if (typeof credOverride === 'string') {
|
|
112
|
-
finalOptions.credentials = credOverride;
|
|
113
|
-
}
|
|
114
|
-
else if (credOverride === true) {
|
|
115
|
-
finalOptions.credentials = 'include';
|
|
116
|
-
}
|
|
117
|
-
else if (typeof credDefault === 'string') {
|
|
118
|
-
finalOptions.credentials = credDefault;
|
|
119
|
-
}
|
|
120
|
-
else if (credDefault === true) {
|
|
121
|
-
finalOptions.credentials = 'include';
|
|
122
|
-
}
|
|
123
|
-
if (method === 'GET' &&
|
|
124
|
-
mergedParams &&
|
|
125
|
-
Object.keys(mergedParams).length) {
|
|
126
|
-
hashIndex = finalUrl.indexOf('#');
|
|
127
|
-
hash = hashIndex >= 0 ? finalUrl.slice(hashIndex) : '';
|
|
128
|
-
basePart = hashIndex >= 0 ? finalUrl.slice(0, hashIndex) : finalUrl;
|
|
129
|
-
searchIndex = basePart.indexOf('?');
|
|
130
|
-
pathname = searchIndex >= 0 ? basePart.slice(0, searchIndex) : basePart;
|
|
131
|
-
existingSearch = searchIndex >= 0 ? basePart.slice(searchIndex + 1) : '';
|
|
132
|
-
searchParams_1 = new URLSearchParams(existingSearch);
|
|
133
|
-
Object.entries(mergedParams).forEach(function (_a) {
|
|
134
|
-
var key = _a[0], value = _a[1];
|
|
135
|
-
if (value == null)
|
|
136
|
-
return;
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
value.forEach(function (v) { return searchParams_1.append(key, String(v)); });
|
|
139
|
-
}
|
|
140
|
-
else if (typeof value === 'object') {
|
|
141
|
-
searchParams_1.append(key, JSON.stringify(value));
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
searchParams_1.append(key, String(value));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
newSearch = searchParams_1.toString();
|
|
148
|
-
finalUrl = pathname + (newSearch ? "?".concat(newSearch) : '') + hash;
|
|
149
|
-
}
|
|
150
|
-
setLoading(true);
|
|
151
|
-
setError(null);
|
|
152
|
-
setData(null);
|
|
153
|
-
controller = new AbortController();
|
|
154
|
-
abortControllerRef.current = controller;
|
|
155
|
-
finalOptions.signal = controller.signal;
|
|
156
|
-
_d.label = 1;
|
|
157
|
-
case 1:
|
|
158
|
-
_d.trys.push([1, 7, 8, 9]);
|
|
159
|
-
return [4 /*yield*/, fetch(finalUrl, finalOptions)];
|
|
160
|
-
case 2:
|
|
161
|
-
response = _d.sent();
|
|
162
|
-
parsed = null;
|
|
163
|
-
_d.label = 3;
|
|
164
|
-
case 3:
|
|
165
|
-
_d.trys.push([3, 5, , 6]);
|
|
166
|
-
return [4 /*yield*/, response.json()];
|
|
167
|
-
case 4:
|
|
168
|
-
parsed = _d.sent();
|
|
169
|
-
return [3 /*break*/, 6];
|
|
170
|
-
case 5:
|
|
171
|
-
_c = _d.sent();
|
|
172
|
-
// non-json or empty body
|
|
173
|
-
parsed = null;
|
|
174
|
-
return [3 /*break*/, 6];
|
|
175
|
-
case 6:
|
|
176
|
-
if (isMounted.current) {
|
|
177
|
-
if (response.ok) {
|
|
178
|
-
setData(parsed);
|
|
179
|
-
setError(null);
|
|
180
|
-
setApiResult(API_RESULT.SUCCESS);
|
|
181
|
-
callback === null || callback === void 0 ? void 0 : callback({
|
|
182
|
-
data: parsed,
|
|
183
|
-
error: null,
|
|
184
|
-
status: response.status,
|
|
185
|
-
ok: true,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
err = new Error("HTTP error! status: ".concat(response.status));
|
|
190
|
-
setError(err);
|
|
191
|
-
setData(parsed);
|
|
192
|
-
setApiResult(API_RESULT.ERROR);
|
|
193
|
-
callback === null || callback === void 0 ? void 0 : callback({
|
|
194
|
-
data: parsed,
|
|
195
|
-
error: err,
|
|
196
|
-
status: response.status,
|
|
197
|
-
ok: false,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return [3 /*break*/, 9];
|
|
202
|
-
case 7:
|
|
203
|
-
err_1 = _d.sent();
|
|
204
|
-
if (isMounted.current) {
|
|
205
|
-
setError(err_1);
|
|
206
|
-
setData(null);
|
|
207
|
-
setApiResult(API_RESULT.ERROR);
|
|
208
|
-
callback === null || callback === void 0 ? void 0 : callback({
|
|
209
|
-
data: null,
|
|
210
|
-
error: err_1,
|
|
211
|
-
status: undefined,
|
|
212
|
-
ok: false,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return [3 /*break*/, 9];
|
|
216
|
-
case 8:
|
|
217
|
-
if (isMounted.current) {
|
|
218
|
-
setLoading(false);
|
|
219
|
-
}
|
|
220
|
-
return [7 /*endfinally*/];
|
|
221
|
-
case 9: return [2 /*return*/];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}); }, __spreadArray([url, defaultOptions, callback], deps, true));
|
|
225
|
-
(0, react_1.useEffect)(function () {
|
|
226
|
-
if (autoFetch && !autoFetchedRef.current) {
|
|
227
|
-
autoFetchedRef.current = true;
|
|
228
|
-
fetchNow();
|
|
229
|
-
}
|
|
230
|
-
}, [fetchNow, autoFetch]);
|
|
231
|
-
return {
|
|
232
|
-
apiResult: apiResult,
|
|
233
|
-
data: data,
|
|
234
|
-
error: error,
|
|
235
|
-
fetchNow: fetchNow,
|
|
236
|
-
loading: loading,
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
exports.useFetch = useFetch;
|
|
1
|
+
var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(r,n)=>{for(var a in n)A(r,a,{get:n[a],enumerable:!0})},V=(r,n,a,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of B(n))!K.call(r,s)&&s!==a&&A(r,s,{get:()=>n[s],enumerable:!(c=z(n,s))||c.enumerable});return r};var W=r=>V(A({},"__esModule",{value:!0}),r);var Y={};Q(Y,{API_RESULT:()=>T,useFetch:()=>X});module.exports=W(Y);var e=require("react"),T=(a=>(a.SUCCESS="SUCCESS",a.ERROR="ERROR",a))(T||{});const X=(r,n={},a=[])=>{const{callback:c,autoFetch:s=!1,...F}=n,[L,h]=(0,e.useState)(null),[j,y]=(0,e.useState)(null),[q,P]=(0,e.useState)(!1),[D,g]=(0,e.useState)(void 0),U=(0,e.useRef)(null),d=(0,e.useRef)(!0),w=(0,e.useRef)(!1);(0,e.useEffect)(()=>(d.current=!0,()=>{d.current=!1,U.current?.abort()}),[]);const S=(0,e.useCallback)(async(N,_)=>{let u=N||r;const{params:G,...b}=F||{},{params:$,...m}=_||{},E={...G||{},...$||{}},l={...b,...m,headers:{...b.headers||{},...m.headers||{}}},H=(l.method||"GET").toString().toUpperCase(),C=m.credentials,O=b.credentials;if(typeof C=="string"?l.credentials=C:C===!0?l.credentials="include":typeof O=="string"?l.credentials=O:O===!0&&(l.credentials="include"),H==="GET"&&E&&Object.keys(E).length){const t=u.indexOf("#"),o=t>=0?u.slice(t):"",i=t>=0?u.slice(0,t):u,p=i.indexOf("?"),J=p>=0?i.slice(0,p):i,M=p>=0?i.slice(p+1):"",R=new URLSearchParams(M);Object.entries(E).forEach(([x,f])=>{f!=null&&(Array.isArray(f)?f.forEach(v=>R.append(x,String(v))):typeof f=="object"?R.append(x,JSON.stringify(f)):R.append(x,String(f)))});const I=R.toString();u=J+(I?`?${I}`:"")+o}P(!0),y(null),h(null);const k=new AbortController;U.current=k,l.signal=k.signal;try{const t=await fetch(u,l);let o=null;try{o=await t.json()}catch{o=null}if(d.current)if(t.ok)h(o),y(null),g("SUCCESS"),c?.({data:o,error:null,status:t.status,ok:!0});else{const i=new Error(`HTTP error! status: ${t.status}`);y(i),h(o),g("ERROR"),c?.({data:o,error:i,status:t.status,ok:!1})}}catch(t){d.current&&(y(t),h(null),g("ERROR"),c?.({data:null,error:t,status:void 0,ok:!1}))}finally{d.current&&P(!1)}},[r,F,c,...a]);return(0,e.useEffect)(()=>{s&&!w.current&&(w.current=!0,S())},[S,s]),{apiResult:D,data:L,error:j,fetchNow:S,loading:q}};0&&(module.exports={API_RESULT,useFetch});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DispatchWithoutAction } from 'react';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* A util hook to enable force renders.
|
|
3
5
|
*
|
|
@@ -6,5 +8,7 @@
|
|
|
6
8
|
* @remarks
|
|
7
9
|
*/
|
|
8
10
|
/** End file docs */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
declare const useForceRender: () => DispatchWithoutAction;
|
|
13
|
+
|
|
14
|
+
export { useForceRender };
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
/**
|
|
3
|
-
* A util hook to enable force renders.
|
|
4
|
-
*
|
|
5
|
-
* @returns dispatch without action
|
|
6
|
-
* @author Taimoor Khan
|
|
7
|
-
* @remarks
|
|
8
|
-
*/
|
|
9
|
-
/** End file docs */
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.useForceRender = void 0;
|
|
12
|
-
var react_1 = require("react");
|
|
13
|
-
var useForceRender = function () {
|
|
14
|
-
var _a = (0, react_1.useReducer)(function (s) { return s + 1; }, 0), dispatch = _a[1];
|
|
15
|
-
return dispatch;
|
|
16
|
-
};
|
|
17
|
-
exports.useForceRender = useForceRender;
|
|
1
|
+
var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var c in t)r(e,c,{get:t[c],enumerable:!0})},a=(e,t,c,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of u(t))!h.call(e,o)&&o!==c&&r(e,o,{get:()=>t[o],enumerable:!(i=s(t,o))||i.enumerable});return e};var d=e=>a(r({},"__esModule",{value:!0}),e);var A={};p(A,{useForceRender:()=>m});module.exports=d(A);var n=require("react");const m=()=>{const[,e]=(0,n.useReducer)(t=>t+1,0);return e};0&&(module.exports={useForceRender});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the user's country based on their IP address via api.country.is.
|
|
3
|
+
*
|
|
4
|
+
* @returns An object with the detected country (or null), any error, and a loading flag.
|
|
5
|
+
*/
|
|
6
|
+
declare const useIPGeoLocation: () => {
|
|
2
7
|
country: string | null;
|
|
3
8
|
error: Error | null;
|
|
4
9
|
isLoading: boolean;
|
|
5
10
|
};
|
|
11
|
+
|
|
12
|
+
export { useIPGeoLocation };
|
|
@@ -1,79 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useIPGeoLocation = void 0;
|
|
40
|
-
var react_1 = require("react");
|
|
41
|
-
var useIPGeoLocation = function () {
|
|
42
|
-
var _a = (0, react_1.useState)(null), country = _a[0], setCountry = _a[1];
|
|
43
|
-
var _b = (0, react_1.useState)(null), error = _b[0], setError = _b[1];
|
|
44
|
-
var _c = (0, react_1.useState)(true), isLoading = _c[0], setIsLoading = _c[1];
|
|
45
|
-
var apiEndpoint = 'https://api.country.is';
|
|
46
|
-
(0, react_1.useEffect)(function () {
|
|
47
|
-
if (country)
|
|
48
|
-
return;
|
|
49
|
-
function fetchAPI() {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
setIsLoading(true);
|
|
55
|
-
return [4 /*yield*/, fetch(apiEndpoint)
|
|
56
|
-
.then(function (res) {
|
|
57
|
-
if (!res.ok) {
|
|
58
|
-
throw Error(res.statusText);
|
|
59
|
-
}
|
|
60
|
-
return res.json();
|
|
61
|
-
})
|
|
62
|
-
.then(function (res) {
|
|
63
|
-
if (res && res.country)
|
|
64
|
-
setCountry(res.country);
|
|
65
|
-
})
|
|
66
|
-
.catch(function (err) { return setError(err); })
|
|
67
|
-
.finally(function () { return setIsLoading(false); })];
|
|
68
|
-
case 1:
|
|
69
|
-
_a.sent();
|
|
70
|
-
return [2 /*return*/];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
fetchAPI();
|
|
76
|
-
}, [country]);
|
|
77
|
-
return { country: country, error: error, isLoading: isLoading };
|
|
78
|
-
};
|
|
79
|
-
exports.useIPGeoLocation = useIPGeoLocation;
|
|
1
|
+
var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var h=(t,o)=>{for(var i in o)s(t,i,{get:o[i],enumerable:!0})},E=(t,o,i,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of y(o))!d.call(t,n)&&n!==i&&s(t,n,{get:()=>o[n],enumerable:!(u=f(o,n))||u.enumerable});return t};var p=t=>E(s({},"__esModule",{value:!0}),t);var L={};h(L,{useIPGeoLocation:()=>g});module.exports=p(L);var e=require("react");const g=()=>{const[t,o]=(0,e.useState)(null),[i,u]=(0,e.useState)(null),[n,c]=(0,e.useState)(!0),l="https://api.country.is";return(0,e.useEffect)(()=>{if(t)return;async function a(){c(!0),await fetch(l).then(r=>{if(!r.ok)throw Error(r.statusText);return r.json()}).then(r=>{r&&r.country&&o(r.country)}).catch(r=>u(r)).finally(()=>c(!1))}a()},[t]),{country:t,error:i,isLoading:n}};0&&(module.exports={useIPGeoLocation});
|
package/hooks/use-is-mobile.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Detects whether the viewport is mobile-sized (width < 767px).
|
|
3
|
+
*
|
|
4
|
+
* @returns True if the viewport width is less than 767 pixels.
|
|
5
|
+
*/
|
|
6
|
+
declare const useIsMobile: () => boolean;
|
|
7
|
+
|
|
8
|
+
export { useIsMobile };
|
package/hooks/use-is-mobile.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsMobile = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useIsMobile = function () {
|
|
6
|
-
var _a = (0, react_1.useState)(false), isMobile = _a[0], setIsMobile = _a[1];
|
|
7
|
-
var handleResize = function () {
|
|
8
|
-
if (window.innerWidth < 767) {
|
|
9
|
-
setIsMobile(true);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
setIsMobile(false);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
(0, react_1.useEffect)(function () {
|
|
16
|
-
window.addEventListener('resize', handleResize);
|
|
17
|
-
handleResize();
|
|
18
|
-
return function () { return window.removeEventListener('resize', handleResize); };
|
|
19
|
-
}, []);
|
|
20
|
-
return isMobile;
|
|
21
|
-
};
|
|
22
|
-
exports.useIsMobile = useIsMobile;
|
|
1
|
+
var t=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var s in e)t(o,s,{get:e[s],enumerable:!0})},u=(o,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of d(e))!a.call(o,i)&&i!==s&&t(o,i,{get:()=>e[i],enumerable:!(r=l(e,i))||r.enumerable});return o};var w=o=>u(t({},"__esModule",{value:!0}),o);var c={};f(c,{useIsMobile:()=>b});module.exports=w(c);var n=require("react");const b=()=>{const[o,e]=(0,n.useState)(!1),s=()=>{window.innerWidth<767?e(!0):e(!1)};return(0,n.useEffect)(()=>(window.addEventListener("resize",s),s(),()=>window.removeEventListener("resize",s)),[]),o};0&&(module.exports={useIsMobile});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FetchConfig } from './use-fetch.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* useModuleEntityV2
|
|
3
5
|
*
|
|
@@ -57,8 +59,8 @@
|
|
|
57
59
|
* updateParams: {}
|
|
58
60
|
* });
|
|
59
61
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
|
|
63
|
+
interface CallbackParamsV2 {
|
|
62
64
|
data: any;
|
|
63
65
|
error: any;
|
|
64
66
|
status?: number;
|
|
@@ -98,5 +100,6 @@ interface Return {
|
|
|
98
100
|
updateFetchNow: (url?: string, config?: FetchConfig) => void;
|
|
99
101
|
updateLoading: boolean;
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
declare const useModuleEntityV2: ({ byIdCallback, byIdDeps, byIdParams, deleteCallback, deleteDeps, deleteParams, listCallback, listDeps, listParams, listUrl, headers, searchQuery, unitByIdUrl, unitUrl, updateCallback, updateDeps, updateParams, }: Params) => Return;
|
|
104
|
+
|
|
105
|
+
export { type CallbackParamsV2, useModuleEntityV2 };
|